Forráskód Böngészése

* more x86_64 parameter fixes
* tparalocation.lochigh is now used to indicate if registerhigh
is used and what the type is

peter 21 éve
szülő
commit
e6929a1a32

+ 9 - 4
compiler/cgbase.pas

@@ -95,7 +95,7 @@ interface
          not be loaded in a register directly }
        TCgSize = (OS_NO,
                  { integer registers }
-                  OS_8,OS_16,OS_32,OS_64,OS_S8,OS_S16,OS_S32,OS_S64,
+                  OS_8,OS_16,OS_32,OS_64,OS_128,OS_S8,OS_S16,OS_S32,OS_S64,OS_S128,
                  { single,double,extended,comp,float128 }
                   OS_F32,OS_F64,OS_F80,OS_C64,OS_F128,
                  { multi-media sizes: split in byte, word, dword, ... }
@@ -223,7 +223,7 @@ interface
 
        tcgsize2size : Array[tcgsize] of integer =
          { integer values }
-        (0,1,2,4,8,1,2,4,8,
+        (0,1,2,4,8,16,1,2,4,8,16,
          { floating point values }
          4,8,EXTENDED_SIZE,8,16,
          { multimedia values }
@@ -238,7 +238,7 @@ interface
        { Table to convert tcgsize variables to the correspondending
          unsigned types }
        tcgsize2unsigned : array[tcgsize] of tcgsize = (OS_NO,
-          OS_8,OS_16,OS_32,OS_64,OS_8,OS_16,OS_32,OS_64,
+          OS_8,OS_16,OS_32,OS_64,OS_128,OS_8,OS_16,OS_32,OS_64,OS_128,
           OS_F32,OS_F64,OS_F80,OS_C64,OS_F128,
           OS_M8,OS_M16,OS_M32,OS_M64,OS_M128,OS_M8,OS_M16,OS_M32,
           OS_M64,OS_M128);
@@ -583,7 +583,12 @@ finalization
 end.
 {
   $Log$
-  Revision 1.86  2004-01-12 22:11:38  peter
+  Revision 1.87  2004-02-09 22:14:17  peter
+    * more x86_64 parameter fixes
+    * tparalocation.lochigh is now used to indicate if registerhigh
+      is used and what the type is
+
+  Revision 1.86  2004/01/12 22:11:38  peter
     * use localalign info for alignment for locals and temps
     * sparc fpu flags branching added
     * moved powerpc copy_valye_openarray to generic

+ 12 - 1
compiler/i386/cpupara.pas

@@ -192,6 +192,7 @@ unit cpupara;
       begin
          fillchar(result,sizeof(tparalocation),0);
          result.size:=OS_INT;
+         result.lochigh:=LOC_INVALID;
          result.alignment:=get_para_align(calloption);
          if calloption=pocall_register then
            begin
@@ -225,6 +226,7 @@ unit cpupara;
         { Function return }
         fillchar(paraloc,sizeof(tparalocation),0);
         paraloc.size:=def_cgsize(p.rettype.def);
+        paraloc.lochigh:=LOC_INVALID;
         { Return in FPU register? }
         if p.rettype.def.deftype=floatdef then
           begin
@@ -277,6 +279,7 @@ unit cpupara;
           begin
             paraloc.size:=def_cgsize(hp.paratype.def);
             paraloc.loc:=LOC_REFERENCE;
+            paraloc.lochigh:=LOC_INVALID;
             paraloc.alignment:=paraalign;
             paraloc.reference.index:=NR_STACK_POINTER_REG;
             l:=push_size(hp.paratyp,hp.paratype.def,p.proccalloption);
@@ -325,6 +328,7 @@ unit cpupara;
             else
               paraloc.size:=def_cgsize(hp.paratype.def);
             paraloc.loc:=LOC_REFERENCE;
+            paraloc.lochigh:=LOC_INVALID;
             paraloc.alignment:=paraalign;
             if side=callerside then
               paraloc.reference.index:=NR_STACK_POINTER_REG
@@ -415,6 +419,7 @@ unit cpupara;
                   ) then
               begin
                 paraloc.loc:=LOC_REGISTER;
+                paraloc.lochigh:=LOC_INVALID;
                 if (paraloc.size=OS_NO) or is_64bit then
                   subreg:=R_SUBWHOLE
                 else
@@ -426,6 +431,7 @@ unit cpupara;
             else
               begin
                 paraloc.loc:=LOC_REFERENCE;
+                paraloc.lochigh:=LOC_INVALID;
                 if side=callerside then
                   paraloc.reference.index:=NR_STACK_POINTER_REG
                 else
@@ -488,7 +494,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.49  2004-02-05 18:28:37  peter
+  Revision 1.50  2004-02-09 22:14:17  peter
+    * more x86_64 parameter fixes
+    * tparalocation.lochigh is now used to indicate if registerhigh
+      is used and what the type is
+
+  Revision 1.49  2004/02/05 18:28:37  peter
     * x86_64 fixes for opsize
 
   Revision 1.48  2003/12/28 22:09:12  florian

+ 3 - 1
compiler/i386/i386att.inc

@@ -199,6 +199,7 @@
 'movsb',
 'movsd',
 'movsl',
+'movsq',
 'movsw',
 'movs',
 'movz',
@@ -562,5 +563,6 @@
 'lddqu',
 'movddup',
 'movshdup',
-'movsldup'
+'movsldup',
+'movabs'
 );

+ 2 - 0
compiler/i386/i386atts.inc

@@ -200,6 +200,7 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
 attsufINT,
 attsufINT,
 attsufINT,
@@ -562,5 +563,6 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
 attsufNONE
 );

+ 3 - 1
compiler/i386/i386int.inc

@@ -199,6 +199,7 @@
 'movsb',
 'movsd',
 'movsl',
+'movsq',
 'movsw',
 'movsx',
 'movzx',
@@ -562,5 +563,6 @@
 'lddqu',
 'movddup',
 'movshdup',
-'movsldup'
+'movsldup',
+'movabs'
 );

+ 3 - 1
compiler/i386/i386op.inc

@@ -199,6 +199,7 @@ A_MOVQ,
 A_MOVSB,
 A_MOVSD,
 A_MOVSL,
+A_MOVSQ,
 A_MOVSW,
 A_MOVSX,
 A_MOVZX,
@@ -562,5 +563,6 @@ A_HSUBPS,
 A_LDDQU,
 A_MOVDDUP,
 A_MOVSHDUP,
-A_MOVSLDUP
+A_MOVSLDUP,
+A_MOVABS
 );

+ 3 - 1
compiler/i386/i386prop.inc

@@ -200,6 +200,7 @@
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_Wop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_Wop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_RWEAX, Ch_WEDX, Ch_WFlags)),
@@ -562,5 +563,6 @@
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
-(Ch: (Ch_All, Ch_None, Ch_None))
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_Wop2, Ch_Rop1, Ch_None))
 );

+ 46 - 46
compiler/i386/i386tab.inc

@@ -795,21 +795,21 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_immediate,ot_none,ot_none);
-    code    : #210#1#232#52;
+    code    : #211#1#232#52;
     flags   : if_8086
   ),
   (
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_immediate or ot_near,ot_none,ot_none);
-    code    : #210#1#232#52;
+    code    : #211#1#232#52;
     flags   : if_8086
   ),
   (
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_immediate or ot_far,ot_none,ot_none);
-    code    : #210#1#154#28#31;
+    code    : #211#1#154#28#31;
     flags   : if_8086
   ),
   (
@@ -858,7 +858,7 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_immediate or ot_immediate,ot_none,ot_none);
-    code    : #210#1#154#29#24;
+    code    : #211#1#154#29#24;
     flags   : if_8086
   ),
   (
@@ -893,7 +893,7 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_memory or ot_far,ot_none,ot_none);
-    code    : #210#192#1#255#131;
+    code    : #211#192#1#255#131;
     flags   : if_8086
   ),
   (
@@ -914,7 +914,7 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_memory or ot_near,ot_none,ot_none);
-    code    : #210#192#1#255#130;
+    code    : #211#192#1#255#130;
     flags   : if_8086
   ),
   (
@@ -949,7 +949,7 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_memory,ot_none,ot_none);
-    code    : #210#192#1#255#130;
+    code    : #211#192#1#255#130;
     flags   : if_8086
   ),
   (
@@ -3259,7 +3259,7 @@
     opcode  : A_IRET;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#207;
+    code    : #211#1#207;
     flags   : if_8086
   ),
   (
@@ -3301,21 +3301,21 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_immediate,ot_none,ot_none);
-    code    : #210#1#233#52;
+    code    : #211#1#233#52;
     flags   : if_8086 or if_pass2
   ),
   (
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_immediate or ot_near,ot_none,ot_none);
-    code    : #210#1#233#52;
+    code    : #211#1#233#52;
     flags   : if_8086 or if_pass2
   ),
   (
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_immediate or ot_far,ot_none,ot_none);
-    code    : #210#1#234#28#31;
+    code    : #211#1#234#28#31;
     flags   : if_8086 or if_pass2
   ),
   (
@@ -3364,7 +3364,7 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_immediate or ot_immediate,ot_none,ot_none);
-    code    : #210#1#234#29#24;
+    code    : #211#1#234#29#24;
     flags   : if_8086
   ),
   (
@@ -3399,7 +3399,7 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_memory or ot_far,ot_none,ot_none);
-    code    : #210#192#1#255#133;
+    code    : #211#192#1#255#133;
     flags   : if_8086
   ),
   (
@@ -3420,7 +3420,7 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_memory or ot_near,ot_none,ot_none);
-    code    : #210#192#1#255#132;
+    code    : #211#192#1#255#132;
     flags   : if_8086
   ),
   (
@@ -3455,7 +3455,7 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_memory,ot_none,ot_none);
-    code    : #210#192#1#255#132;
+    code    : #211#192#1#255#132;
     flags   : if_8086
   ),
   (
@@ -3511,7 +3511,7 @@
     opcode  : A_LCALL;
     ops     : 1;
     optypes : (ot_memory or ot_far,ot_none,ot_none);
-    code    : #210#192#1#255#131;
+    code    : #211#192#1#255#131;
     flags   : if_8086
   ),
   (
@@ -3532,7 +3532,7 @@
     opcode  : A_LCALL;
     ops     : 1;
     optypes : (ot_memory or ot_near,ot_none,ot_none);
-    code    : #210#192#1#255#130;
+    code    : #211#192#1#255#130;
     flags   : if_8086
   ),
   (
@@ -3567,7 +3567,7 @@
     opcode  : A_LCALL;
     ops     : 1;
     optypes : (ot_memory,ot_none,ot_none);
-    code    : #210#192#1#255#130;
+    code    : #211#192#1#255#130;
     flags   : if_8086
   ),
   (
@@ -3686,7 +3686,7 @@
     opcode  : A_LJMP;
     ops     : 1;
     optypes : (ot_memory or ot_far,ot_none,ot_none);
-    code    : #210#192#1#255#133;
+    code    : #211#192#1#255#133;
     flags   : if_8086
   ),
   (
@@ -3707,7 +3707,7 @@
     opcode  : A_LJMP;
     ops     : 1;
     optypes : (ot_memory or ot_near,ot_none,ot_none);
-    code    : #210#192#1#255#132;
+    code    : #211#192#1#255#132;
     flags   : if_8086
   ),
   (
@@ -3742,7 +3742,7 @@
     opcode  : A_LJMP;
     ops     : 1;
     optypes : (ot_memory,ot_none,ot_none);
-    code    : #210#192#1#255#132;
+    code    : #211#192#1#255#132;
     flags   : if_8086
   ),
   (
@@ -4135,70 +4135,70 @@
     ops     : 2;
     optypes : (ot_reg_al,ot_mem_offs,ot_none);
     code    : #193#1#160#29;
-    flags   : if_8086 or if_sm
+    flags   : if_8086 or if_sm or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg_ax,ot_mem_offs,ot_none);
     code    : #193#208#1#161#29;
-    flags   : if_8086 or if_sm
+    flags   : if_8086 or if_sm or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg_eax,ot_mem_offs,ot_none);
     code    : #193#209#1#161#29;
-    flags   : if_386 or if_sm
+    flags   : if_386 or if_sm or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_mem_offs,ot_reg_al,ot_none);
     code    : #192#1#162#28;
-    flags   : if_8086 or if_sm
+    flags   : if_8086 or if_sm or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_mem_offs,ot_reg_ax,ot_none);
     code    : #192#208#1#163#28;
-    flags   : if_8086 or if_sm
+    flags   : if_8086 or if_sm or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_mem_offs,ot_reg_eax,ot_none);
     code    : #192#209#1#163#28;
-    flags   : if_386 or if_sm
+    flags   : if_386 or if_sm or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg32,ot_reg_cr4,ot_none);
     code    : #2#15#32#132;
-    flags   : if_pent or if_priv
+    flags   : if_pent or if_priv or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg32,ot_reg_creg,ot_none);
     code    : #2#15#32#65;
-    flags   : if_386 or if_priv
+    flags   : if_386 or if_priv or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg32,ot_reg_dreg,ot_none);
     code    : #2#15#33#65;
-    flags   : if_386 or if_priv
+    flags   : if_386 or if_priv or if_nox86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg32,ot_reg_treg,ot_none);
     code    : #2#15#36#65;
-    flags   : if_386 or if_priv
+    flags   : if_386 or if_priv or if_nox86_64
   ),
   (
     opcode  : A_MOV;
@@ -5926,7 +5926,7 @@
     opcode  : A_POPA;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#97;
+    code    : #211#1#97;
     flags   : if_186
   ),
   (
@@ -5947,7 +5947,7 @@
     opcode  : A_POPF;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#157;
+    code    : #211#1#157;
     flags   : if_186
   ),
   (
@@ -6732,69 +6732,69 @@
     ops     : 1;
     optypes : (ot_reg16,ot_none,ot_none);
     code    : #208#8#80;
-    flags   : if_8086
+    flags   : if_8086 or if_nox86_64
   ),
   (
     opcode  : A_PUSH;
     ops     : 1;
     optypes : (ot_reg32,ot_none,ot_none);
     code    : #209#8#80;
-    flags   : if_386
+    flags   : if_386 or if_nox86_64
   ),
   (
     opcode  : A_PUSH;
     ops     : 1;
     optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
     code    : #208#192#1#255#134;
-    flags   : if_8086
+    flags   : if_8086 or if_nox86_64
   ),
   (
     opcode  : A_PUSH;
     ops     : 1;
     optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
     code    : #209#192#1#255#134;
-    flags   : if_386
+    flags   : if_386 or if_nox86_64
   ),
   (
     opcode  : A_PUSH;
     ops     : 1;
     optypes : (ot_reg_fsgs,ot_none,ot_none);
     code    : #1#15#7;
-    flags   : if_386
+    flags   : if_386 or if_nox86_64
   ),
   (
     opcode  : A_PUSH;
     ops     : 1;
     optypes : (ot_reg_sreg,ot_none,ot_none);
     code    : #6;
-    flags   : if_8086
+    flags   : if_8086 or if_nox86_64
   ),
   (
     opcode  : A_PUSH;
     ops     : 1;
     optypes : (ot_immediate or ot_bits8 or ot_signed,ot_none,ot_none);
     code    : #1#106#12;
-    flags   : if_286
+    flags   : if_286 or if_nox86_64
   ),
   (
     opcode  : A_PUSH;
     ops     : 1;
     optypes : (ot_immediate or ot_bits16,ot_none,ot_none);
     code    : #208#1#104#24;
-    flags   : if_286
+    flags   : if_286 or if_nox86_64
   ),
   (
     opcode  : A_PUSH;
     ops     : 1;
     optypes : (ot_immediate or ot_bits32,ot_none,ot_none);
     code    : #209#1#104#32;
-    flags   : if_386
+    flags   : if_386 or if_nox86_64
   ),
   (
     opcode  : A_PUSHA;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#96;
+    code    : #211#1#96;
     flags   : if_186
   ),
   (
@@ -6815,7 +6815,7 @@
     opcode  : A_PUSHF;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#156;
+    code    : #211#1#156;
     flags   : if_186
   ),
   (
@@ -7243,7 +7243,7 @@
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
     code    : #1#158;
-    flags   : if_8086
+    flags   : if_8086 or if_nox86_64
   ),
   (
     opcode  : A_SAL;
@@ -8894,7 +8894,7 @@
     opcode  : A_Jcc;
     ops     : 1;
     optypes : (ot_immediate or ot_near,ot_none,ot_none);
-    code    : #210#1#15#216#128#52;
+    code    : #211#1#15#216#128#52;
     flags   : if_386 or if_pass2
   ),
   (

+ 109 - 58
compiler/paramgr.pas

@@ -297,85 +297,127 @@ implementation
     procedure tparamanager.allocparaloc(list: taasmoutput; const loc: tparalocation);
       begin
         case loc.loc of
-          LOC_REGISTER, LOC_CREGISTER:
+          LOC_REGISTER,
+          LOC_CREGISTER,
+          LOC_FPUREGISTER,
+          LOC_CFPUREGISTER,
+          LOC_MMREGISTER,
+          LOC_CMMREGISTER :
             begin
               { NR_NO means we don't need to allocate the parameter.
                 This is used for inlining parameters which allocates
                 the parameters in gen_alloc_parast (PFV) }
-              if loc.register<>NR_NO then
-                begin
-{$ifndef cpu64bit}
-                  if (loc.size in [OS_64,OS_S64,OS_F64]) then
-                    begin
-                      cg.getexplicitregister(list,loc.registerhigh);
-                      cg.getexplicitregister(list,loc.registerlow);
-                    end
-                  else
-{$endif cpu64bit}
-                    cg.getexplicitregister(list,loc.register);
-                end;
-            end;
-          LOC_FPUREGISTER, LOC_CFPUREGISTER:
-            begin
               if loc.register<>NR_NO then
                 cg.getexplicitregister(list,loc.register);
             end;
-          LOC_REFERENCE,LOC_CREFERENCE:
+          LOC_REFERENCE,
+          LOC_CREFERENCE :
             { do nothing by default, most of the time it's the framepointer }
           else
             internalerror(200306091);
         end;
+        case loc.lochigh of
+          LOC_INVALID :
+            ;
+          LOC_REGISTER,
+          LOC_CREGISTER,
+          LOC_FPUREGISTER,
+          LOC_CFPUREGISTER,
+          LOC_MMREGISTER,
+          LOC_CMMREGISTER :
+            begin
+              { NR_NO means we don't need to allocate the parameter.
+                This is used for inlining parameters which allocates
+                the parameters in gen_alloc_parast (PFV) }
+              if loc.registerhigh<>NR_NO then
+                cg.getexplicitregister(list,loc.registerhigh);
+            end;
+          else
+            internalerror(200306091);
+        end;
       end;
 
 
     procedure tparamanager.freeparaloc(list: taasmoutput; const loc: tparalocation);
       begin
         case loc.loc of
-          LOC_REGISTER, LOC_CREGISTER:
-            begin
-{$ifndef cpu64bit}
-              if (loc.size in [OS_64,OS_S64,OS_F64]) then
-                begin
-                  cg.ungetregister(list,loc.registerhigh);
-                  cg.ungetregister(list,loc.registerlow);
-                end
-              else
-{$endif cpu64bit}
-                cg.ungetregister(list,loc.register);
-            end;
-          LOC_FPUREGISTER, LOC_CFPUREGISTER:
+          LOC_REGISTER,
+          LOC_CREGISTER,
+          LOC_FPUREGISTER,
+          LOC_CFPUREGISTER,
+          LOC_MMREGISTER,
+          LOC_CMMREGISTER :
             cg.ungetregister(list,loc.register);
           LOC_REFERENCE,LOC_CREFERENCE:
             { do nothing by default, most of the time it's the framepointer }
           else
             internalerror(200306091);
         end;
+        case loc.lochigh of
+          LOC_INVALID :
+            ;
+          LOC_REGISTER,
+          LOC_CREGISTER,
+          LOC_FPUREGISTER,
+          LOC_CFPUREGISTER,
+          LOC_MMREGISTER,
+          LOC_CMMREGISTER :
+            cg.ungetregister(list,loc.register);
+          else
+            internalerror(200306091);
+        end;
       end;
 
 
     procedure tparamanager.splitparaloc64(const locpara:tparalocation;var loclopara,lochipara:tparalocation);
       begin
-        if not(locpara.size in [OS_64,OS_S64]) then
-          internalerror(200307023);
         lochipara:=locpara;
         loclopara:=locpara;
-        if locpara.size=OS_S64 then
-          lochipara.size:=OS_S32
-        else
-          lochipara.size:=OS_32;
-        loclopara.size:=OS_32;
+        case locpara.size of
+          OS_S128 :
+            begin
+              lochipara.size:=OS_S64;
+              loclopara.size:=OS_64;
+            end;
+          OS_128 :
+            begin
+              lochipara.size:=OS_64;
+              loclopara.size:=OS_64;
+            end;
+          OS_S64 :
+            begin
+              lochipara.size:=OS_S32;
+              loclopara.size:=OS_32;
+            end;
+          OS_64 :
+            begin
+              lochipara.size:=OS_32;
+              loclopara.size:=OS_32;
+            end;
+          else
+            internalerror(200307023);
+        end;
+        loclopara.lochigh:=LOC_INVALID;
+        lochipara.lochigh:=LOC_INVALID;
         case locpara.loc of
-           LOC_REGISTER,LOC_CREGISTER:
+           LOC_REGISTER,
+           LOC_CREGISTER,
+           LOC_FPUREGISTER,
+           LOC_CFPUREGISTER,
+           LOC_MMREGISTER,
+           LOC_CMMREGISTER :
              begin
+               if locpara.lochigh=LOC_INVALID then
+                 internalerror(200402061);
                loclopara.register:=locpara.registerlow;
                lochipara.register:=locpara.registerhigh;
              end;
            LOC_REFERENCE:
              begin
                if target_info.endian=endian_big then
-                 inc(loclopara.reference.offset,4)
+                 inc(loclopara.reference.offset,tcgsize2size[loclopara.size])
                else
-                 inc(lochipara.reference.offset,4);
+                 inc(lochipara.reference.offset,tcgsize2size[loclopara.size]);
              end;
            else
              internalerror(200307024);
@@ -384,28 +426,32 @@ implementation
 
 
     procedure tparamanager.alloctempregs(list: taasmoutput;var locpara:tparalocation);
+      var
+        cgsize : tcgsize;
       begin
+        if locpara.lochigh<>LOC_INVALID then
+          cgsize:=OS_INT
+        else
+          cgsize:=locpara.size;
         case locpara.loc of
           LOC_REGISTER:
-            begin
-{$ifndef cpu64bit}
-              if locpara.size in [OS_64,OS_S64] then
-                begin
-                  locpara.registerlow:=cg.getintregister(list,OS_32);
-                  locpara.registerhigh:=cg.getintregister(list,OS_32);
-                end
-              else
-{$endif cpu64bit}
-                locpara.register:=cg.getintregister(list,locpara.size);
-            end;
+            locpara.register:=cg.getintregister(list,cgsize);
           LOC_FPUREGISTER:
-            begin
-              locpara.register:=cg.getfpuregister(list,locpara.size);
-            end;
+            locpara.register:=cg.getfpuregister(list,cgsize);
           LOC_MMREGISTER:
-            begin
-              locpara.register:=cg.getfpuregister(list,locpara.size);
-            end;
+            locpara.register:=cg.getmmregister(list,cgsize);
+          else
+            internalerror(200308123);
+        end;
+        case locpara.lochigh of
+          LOC_INVALID:
+            ;
+          LOC_REGISTER:
+            locpara.registerhigh:=cg.getintregister(list,cgsize);
+          LOC_FPUREGISTER:
+            locpara.registerhigh:=cg.getfpuregister(list,cgsize);
+          LOC_MMREGISTER:
+            locpara.registerhigh:=cg.getmmregister(list,cgsize);
           else
             internalerror(200308123);
         end;
@@ -458,7 +504,12 @@ end.
 
 {
    $Log$
-   Revision 1.68  2003-12-28 22:09:12  florian
+   Revision 1.69  2004-02-09 22:14:17  peter
+     * more x86_64 parameter fixes
+     * tparalocation.lochigh is now used to indicate if registerhigh
+       is used and what the type is
+
+   Revision 1.68  2003/12/28 22:09:12  florian
      + setting of bit 6 of cr for c var args on ppc implemented
 
    Revision 1.67  2003/12/06 01:15:22  florian

+ 20 - 6
compiler/x86/aasmcpu.pas

@@ -252,6 +252,7 @@ implementation
        IF_PRIV   = $00000100;  { it's a privileged instruction  }
        IF_SMM    = $00000200;  { it's only valid in SMM  }
        IF_PROT   = $00000400;  { it's protected mode only  }
+       IF_NOX86_64 = $00000800;  { removed instruction in x86_64  }
        IF_UNDOC  = $00001000;  { it's an undocumented instruction  }
        IF_FPU    = $00002000;  { it's an FPU instruction  }
        IF_MMX    = $00004000;  { it's an MMX instruction  }
@@ -264,7 +265,7 @@ implementation
        { SSE3 instructions  }
        IF_SSE3   = $00040000;
        { SSE64 instructions  }
-       IF_SSE64   = $00040000;
+       IF_SSE64  = $00080000;
        { the mask for processor types  }
        {IF_PMASK  = longint($FF000000);}
        { the mask for disassembly "prefer"  }
@@ -1512,13 +1513,14 @@ implementation
             192,193,194 :
               if NeedAddrPrefix(c-192) then
                inc(len);
-            208 :
+            208,
+            210 :
               inc(len);
             200,
             201,
             202,
             209,
-            210,
+            211,
             217,218: ;
             219,220 :
               inc(len);
@@ -1584,9 +1586,11 @@ implementation
        *                 the memory reference in operand x.
        * \310          - indicates fixed 16-bit address size, i.e. optional 0x67.
        * \311          - indicates fixed 32-bit address size, i.e. optional 0x67.
+       * \312          - indicates fixed 64-bit address size, i.e. optional 0x48.
        * \320          - indicates fixed 16-bit operand size, i.e. optional 0x66.
        * \321          - indicates fixed 32-bit operand size, i.e. optional 0x66.
-       * \322          - indicates that this instruction is only valid when the
+       * \322          - indicates fixed 64-bit operand size, i.e. optional 0x48.
+       * \323          - indicates that this instruction is only valid when the
        *                 operand size is the default (instruction to disassembler,
        *                 generates no code in the assembler)
        * \330          - a literal byte follows in the code stream, to be added
@@ -1805,6 +1809,11 @@ implementation
                 bytes[0]:=$66;
                 sec.writebytes(bytes,1);
               end;
+            210 :
+              begin
+                bytes[0]:=$48;
+                sec.writebytes(bytes,1);
+              end;
             216 :
               begin
                 bytes[0]:=ord(codes^)+condval[condition];
@@ -1814,7 +1823,7 @@ implementation
             201,
             202,
             209,
-            210,
+            211,
             217,218 :
               begin
                 { these are dissambler hints or 32 bit prefixes which
@@ -1955,7 +1964,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.50  2004-02-08 23:10:21  jonas
+  Revision 1.51  2004-02-09 22:14:17  peter
+    * more x86_64 parameter fixes
+    * tparalocation.lochigh is now used to indicate if registerhigh
+      is used and what the type is
+
+  Revision 1.50  2004/02/08 23:10:21  jonas
     * taicpu.is_same_reg_move() now gets a regtype parameter so it only
       removes moves of that particular register type. This is necessary so
       we don't remove the live_start instruction of a register before it

+ 55 - 22
compiler/x86/cgx86.pas

@@ -149,12 +149,12 @@ unit cgx86;
    const
 {$ifdef x86_64}
       TCGSize2OpSize: Array[tcgsize] of topsize =
-        (S_NO,S_B,S_W,S_L,S_Q,S_B,S_W,S_L,S_Q,
+        (S_NO,S_B,S_W,S_L,S_Q,S_Q,S_B,S_W,S_L,S_Q,S_Q,
          S_FS,S_FL,S_FX,S_IQ,S_FXX,
          S_NO,S_NO,S_NO,S_MD,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO);
 {$else x86_64}
       TCGSize2OpSize: Array[tcgsize] of topsize =
-        (S_NO,S_B,S_W,S_L,S_L,S_B,S_W,S_L,S_L,
+        (S_NO,S_B,S_W,S_L,S_L,S_L,S_B,S_W,S_L,S_L,S_L,
          S_FS,S_FL,S_FX,S_IQ,S_FXX,
          S_NO,S_NO,S_NO,S_MD,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO);
 {$endif x86_64}
@@ -1281,6 +1281,17 @@ unit cgx86;
     procedure Tcgx86.g_concatcopy(list:Taasmoutput;const source,dest:Treference;
                                   len:aword;delsource,loadref:boolean);
 
+    const
+{$ifdef cpu64bit}
+        REGCX=NR_RCX;
+        REGSI=NR_RSI;
+        REGDI=NR_RDI;
+{$else cpu64bit}
+        REGCX=NR_ECX;
+        REGSI=NR_ESI;
+        REGDI=NR_EDI;
+{$endif cpu64bit}
+
     type  copymode=(copy_move,copy_mmx,copy_string);
 
     var srcref,dstref:Treference;
@@ -1311,8 +1322,8 @@ unit cgx86;
           begin
             dstref:=dest;
             srcref:=source;
-            copysize:=4;
-            cgsize:=OS_32;
+            copysize:=sizeof(aword);
+            cgsize:=int_cgsize(copysize);
             while len<>0 do
               begin
                 if len<2 then
@@ -1324,6 +1335,11 @@ unit cgx86;
                   begin
                     copysize:=2;
                     cgsize:=OS_16;
+                  end
+                else if len<8 then
+                  begin
+                    copysize:=4;
+                    cgsize:=OS_32;
                   end;
                 dec(len,copysize);
                 if (len=0) and delsource then
@@ -1383,47 +1399,59 @@ unit cgx86;
           end
         else {copy_string, should be a good fallback in case of unhandled}
           begin
-            getexplicitregister(list,NR_EDI);
-            a_loadaddr_ref_reg(list,dest,NR_EDI);
-            getexplicitregister(list,NR_ESI);
+            getexplicitregister(list,REGDI);
+            a_loadaddr_ref_reg(list,dest,REGDI);
+            getexplicitregister(list,REGSI);
             if loadref then
-              a_load_ref_reg(list,OS_ADDR,OS_ADDR,source,NR_ESI)
+              a_load_ref_reg(list,OS_ADDR,OS_ADDR,source,REGSI)
             else
               begin
-                a_loadaddr_ref_reg(list,source,NR_ESI);
+                a_loadaddr_ref_reg(list,source,REGSI);
                 if delsource then
                   begin
                     srcref:=source;
                     { Don't release ESI register yet, it's needed
                       by the movsl }
-                    if (srcref.base=NR_ESI) then
+                    if (srcref.base=REGSI) then
                       srcref.base:=NR_NO
-                    else if (srcref.index=NR_ESI) then
+                    else if (srcref.index=REGSI) then
                       srcref.index:=NR_NO;
                     reference_release(list,srcref);
                   end;
               end;
 
-            getexplicitregister(list,NR_ECX);
+            getexplicitregister(list,REGCX);
 
             list.concat(Taicpu.op_none(A_CLD,S_NO));
             if cs_littlesize in aktglobalswitches  then
               begin
-                a_load_const_reg(list,OS_INT,len,NR_ECX);
+                a_load_const_reg(list,OS_INT,len,REGCX);
                 list.concat(Taicpu.op_none(A_REP,S_NO));
                 list.concat(Taicpu.op_none(A_MOVSB,S_NO));
               end
             else
               begin
-                helpsize:=len shr 2;
-                len:=len and 3;
+                helpsize:=len div sizeof(aword);
+                len:=len mod sizeof(aword);
                 if helpsize>1 then
                   begin
-                    a_load_const_reg(list,OS_INT,helpsize,NR_ECX);
+                    a_load_const_reg(list,OS_INT,helpsize,REGCX);
                     list.concat(Taicpu.op_none(A_REP,S_NO));
                   end;
                 if helpsize>0 then
-                  list.concat(Taicpu.op_none(A_MOVSL,S_NO));
+                  begin
+{$ifdef cpu64bit}
+                    if sizeof(aword)=8 then
+                      list.concat(Taicpu.op_none(A_MOVSQ,S_NO))
+                    else
+{$endif cpu64bit}
+                      list.concat(Taicpu.op_none(A_MOVSL,S_NO));
+                  end;
+                if len>2 then
+                  begin
+                    dec(len,4);
+                    list.concat(Taicpu.op_none(A_MOVSL,S_NO));
+                  end;
                 if len>1 then
                   begin
                     dec(len,2);
@@ -1431,10 +1459,10 @@ unit cgx86;
                   end;
                 if len=1 then
                   list.concat(Taicpu.op_none(A_MOVSB,S_NO));
-                end;
-            ungetregister(list,NR_ECX);
-            ungetregister(list,NR_ESI);
-            ungetregister(list,NR_EDI);
+              end;
+            ungetregister(list,REGCX);
+            ungetregister(list,REGSI);
+            ungetregister(list,REGDI);
           end;
         end;
       if delsource then
@@ -1852,7 +1880,12 @@ unit cgx86;
 end.
 {
   $Log$
-  Revision 1.109  2004-02-07 23:28:34  daniel
+  Revision 1.110  2004-02-09 22:14:17  peter
+    * more x86_64 parameter fixes
+    * tparalocation.lochigh is now used to indicate if registerhigh
+      is used and what the type is
+
+  Revision 1.109  2004/02/07 23:28:34  daniel
     * Take advantage of our new with statement optimization
 
   Revision 1.108  2004/02/06 14:37:48  florian

+ 61 - 62
compiler/x86/x86ins.dat

@@ -12,11 +12,6 @@
 ; arguments   bytes   flags
 ;
 
-;*****************************************************************************************
-; Insert i386 instructions only above the line ;!!!x86_64 ! x86-64 only instructions go
-; below this line
-;*****************************************************************************************
-
 [NONE]
 (Ch_None, Ch_None, Ch_None)
 void                  void                            none
@@ -184,29 +179,29 @@ rm32,imm              \321\300\2\x0F\xBA\205\25       386,SB
 [CALL,call]
 ; don't know value of any register
 (Ch_ROp1, Ch_All, Ch_None)
-imm                   \322\1\xE8\64                   8086
-imm|near              \322\1\xE8\64                   8086
-imm|far               \322\1\x9A\34\37                8086,ND
+imm                   \323\1\xE8\64                   8086
+imm|near              \323\1\xE8\64                   8086
+imm|far               \323\1\x9A\34\37                8086,ND
 imm16                 \320\1\xE8\64                   8086
 imm16|near            \320\1\xE8\64                   8086
 imm16|far             \320\1\x9A\34\37                8086,ND
 imm32                 \321\1\xE8\64                   8086
 imm32|near            \321\1\xE8\64                   8086
 imm32|far             \321\1\x9A\34\37                8086,ND
-imm:imm               \322\1\x9A\35\30                8086
+imm:imm               \323\1\x9A\35\30                8086
 imm16:imm             \320\1\x9A\31\30                8086
 imm:imm16             \320\1\x9A\31\30                8086
 imm32:imm             \321\1\x9A\41\30                386
 imm:imm32             \321\1\x9A\41\30                386
-mem|far               \322\300\1\xFF\203              8086
+mem|far               \323\300\1\xFF\203              8086
 mem16|far             \320\300\1\xFF\203              8086
 mem32|far             \321\300\1\xFF\203              386
-mem|near              \322\300\1\xFF\202              8086
+mem|near              \323\300\1\xFF\202              8086
 mem16|near            \320\300\1\xFF\202              8086
 mem32|near            \321\300\1\xFF\202              386
 reg16                 \320\300\1\xFF\202              8086
 reg32                 \321\300\1\xFF\202              386
-mem                   \322\300\1\xFF\202              8086
+mem                   \323\300\1\xFF\202              8086
 mem16                 \320\300\1\xFF\202              8086
 mem32                 \321\300\1\xFF\202              386
 
@@ -959,7 +954,7 @@ mem                   \300\2\x0F\x01\207              486,PRIV
 
 [IRET]
 (Ch_All, Ch_None, Ch_None)
-void                  \322\1\xCF                      8086
+void                  \323\1\xCF                      8086
 
 [IRETD,iret]
 (Ch_All, Ch_None, Ch_None)
@@ -980,29 +975,29 @@ imm                   \321\1\xE3\50                   386
 [JMP,jmpX]
 (Ch_ROp1, Ch_None, Ch_None)
 imm|short             \1\xEB\50                       8086,PASS2
-imm                   \322\1\xE9\64                   8086,PASS2
-imm|near              \322\1\xE9\64                   8086,ND,PASS2
-imm|far               \322\1\xEA\34\37                8086,ND,PASS2
+imm                   \323\1\xE9\64                   8086,PASS2
+imm|near              \323\1\xE9\64                   8086,ND,PASS2
+imm|far               \323\1\xEA\34\37                8086,ND,PASS2
 imm16                 \320\1\xE9\64                   8086,PASS2
 imm16|near            \320\1\xE9\64                   8086,ND,PASS2
 imm16|far             \320\1\xEA\34\37                8086,ND,PASS2
 imm32                 \321\1\xE9\64                   8086,PASS2
 imm32|near            \321\1\xE9\64                   8086,ND,PASS2
 imm32|far             \321\1\xEA\34\37                8086,ND,PASS2
-imm:imm               \322\1\xEA\35\30                8086
+imm:imm               \323\1\xEA\35\30                8086
 imm16:imm             \320\1\xEA\31\30                8086
 imm:imm16             \320\1\xEA\31\30                8086
 imm32:imm             \321\1\xEA\41\30                386
 imm:imm32             \321\1\xEA\41\30                386
-mem|far               \322\300\1\xFF\205              8086
+mem|far               \323\300\1\xFF\205              8086
 mem16|far             \320\300\1\xFF\205              8086
 mem32|far             \321\300\1\xFF\205              386
-mem|near              \322\300\1\xFF\204              8086
+mem|near              \323\300\1\xFF\204              8086
 mem16|near            \320\300\1\xFF\204              8086
 mem32|near            \321\300\1\xFF\204              386
 reg16                 \320\300\1\xFF\204              8086
 reg32                 \321\300\1\xFF\204              386
-mem                   \322\300\1\xFF\204              8086
+mem                   \323\300\1\xFF\204              8086
 mem16                 \320\300\1\xFF\204              8086
 mem32                 \321\300\1\xFF\204              386
 
@@ -1020,15 +1015,15 @@ reg32,reg32           \321\301\2\x0F\x02\110          286,PROT
 [LCALL,lcall]
 ; don't know value of any register
 (Ch_All, Ch_None, Ch_None)
-mem|far               \322\300\1\xFF\203              8086
+mem|far               \323\300\1\xFF\203              8086
 mem16|far             \320\300\1\xFF\203              8086
 mem32|far             \321\300\1\xFF\203              386
-mem|near              \322\300\1\xFF\202              8086
+mem|near              \323\300\1\xFF\202              8086
 mem16|near            \320\300\1\xFF\202              8086
 mem32|near            \321\300\1\xFF\202              386
 reg16                 \320\300\1\xFF\202              8086
 reg32                 \321\300\1\xFF\202              386
-mem                   \322\300\1\xFF\202              8086
+mem                   \323\300\1\xFF\202              8086
 mem16                 \320\300\1\xFF\202              8086
 mem32                 \321\300\1\xFF\202              386
 
@@ -1072,15 +1067,15 @@ mem                   \300\2\x0F\x01\203              286,PRIV
 
 [LJMP,ljmp]
 (Ch_ROp1, Ch_None, Ch_None)
-mem|far               \322\300\1\xFF\205              8086
+mem|far               \323\300\1\xFF\205              8086
 mem16|far             \320\300\1\xFF\205              8086
 mem32|far             \321\300\1\xFF\205              386
-mem|near              \322\300\1\xFF\204              8086
+mem|near              \323\300\1\xFF\204              8086
 mem16|near            \320\300\1\xFF\204              8086
 mem32|near            \321\300\1\xFF\204              386
 reg16                 \320\300\1\xFF\204              8086
 reg32                 \321\300\1\xFF\204              386
-mem                   \322\300\1\xFF\204              8086
+mem                   \323\300\1\xFF\204              8086
 mem16                 \320\300\1\xFF\204              8086
 mem32                 \321\300\1\xFF\204              386
 
@@ -1190,16 +1185,20 @@ reg_dess,reg16        \320\301\1\x8E\110              8086
 reg_fsgs,reg16        \320\301\1\x8E\110              386
 reg_dess,rm32         \321\301\1\x8E\110              8086
 reg_fsgs,rm32         \321\301\1\x8E\110              386
-reg_al,mem_offs       \301\1\xA0\35                   8086,SM
-reg_ax,mem_offs       \301\320\1\xA1\35               8086,SM
-reg_eax,mem_offs      \301\321\1\xA1\35               386,SM
-mem_offs,reg_al       \300\1\xA2\34                   8086,SM
-mem_offs,reg_ax       \300\320\1\xA3\34               8086,SM
-mem_offs,reg_eax      \300\321\1\xA3\34               386,SM
-reg32,reg_cr4         \2\x0F\x20\204                  PENT,PRIV
-reg32,reg_creg        \2\x0F\x20\101                  386,PRIV
-reg32,reg_dreg        \2\x0F\x21\101                  386,PRIV
-reg32,reg_treg        \2\x0F\x24\101                  386,PRIV
+reg_al,mem_offs       \301\1\xA0\35                   8086,SM,NOX86_64
+reg_ax,mem_offs       \301\320\1\xA1\35               8086,SM,NOX86_64
+reg_eax,mem_offs      \301\321\1\xA1\35               386,SM,NOX86_64
+mem_offs,reg_al       \300\1\xA2\34                   8086,SM,NOX86_64
+mem_offs,reg_ax       \300\320\1\xA3\34               8086,SM,NOX86_64
+mem_offs,reg_eax      \300\321\1\xA3\34               386,SM,NOX86_64
+reg32,reg_cr4         \2\x0F\x20\204                  PENT,PRIV,NOX86_64
+reg32,reg_creg        \2\x0F\x20\101                  386,PRIV,NOX86_64
+reg32,reg_dreg        \2\x0F\x21\101                  386,PRIV,NOX86_64
+reg32,reg_treg        \2\x0F\x24\101                  386,PRIV,NOX86_64
+reg64,reg_cr4         \2\x0F\x20\204                  PENT,PRIV,X86_64
+reg64,reg_creg        \2\x0F\x20\101                  386,PRIV,X86_64
+reg64,reg_dreg        \2\x0F\x21\101                  386,PRIV,X86_64
+reg64,reg_treg        \2\x0F\x24\101                  386,PRIV,X86_64
 reg_cr4,reg32         \2\x0F\x22\214                  PENT,PRIV
 reg_creg,reg32        \2\x0F\x22\110                  386,PRIV
 reg_dreg,reg32        \2\x0F\x23\110                  386,PRIV
@@ -1265,6 +1264,10 @@ xmmreg,mem            \301\3\xF2\x0F\x10\110          WILLAMETTE,SSE2
 (Ch_All, Ch_None, Ch_None)
 void                  \321\1\xA5                      386
 
+[MOVSQ]
+(Ch_All, Ch_None, Ch_None)
+void                  \322\1\xA5                      X86_64
+
 [MOVSW]
 (Ch_All, Ch_None, Ch_None)
 void                  \320\1\xA5                      8086
@@ -1661,7 +1664,7 @@ reg_fsgs              \1\x0F\5                        386
 
 [POPA,popaX]
 (Ch_All, Ch_None, Ch_None)
-void                  \322\1\x61                      186
+void                  \323\1\x61                      186
 
 [POPAD,popal]
 (Ch_All, Ch_None, Ch_None)
@@ -1673,7 +1676,7 @@ void                  \320\1\x61                      186
 
 [POPF]
 (Ch_RWESP, Ch_WFlags, Ch_None)
-void                  \322\1\x9D                      186
+void                  \323\1\x9D                      186
 
 [POPFD,popfl]
 (Ch_RWESP, Ch_WFlags, Ch_None)
@@ -1872,19 +1875,19 @@ xmmreg,xmmreg         \3\x66\x0F\x61\110              WILLAMETTE,SSE2
 
 [PUSH,pushX]
 (Ch_Rop1, Ch_RWESP, Ch_None)
-reg16                 \320\10\x50                     8086
-reg32                 \321\10\x50                     386
-rm16                  \320\300\1\xFF\206              8086
-rm32                  \321\300\1\xFF\206              386
-reg_fsgs              \1\x0F\7                        386
-reg_sreg              \6                              8086
-imm8                  \1\x6A\14                       286
-imm16                 \320\1\x68\30                   286
-imm32                 \321\1\x68\40                   386
+reg16                 \320\10\x50                     8086,NOX86_64
+reg32                 \321\10\x50                     386,NOX86_64
+rm16                  \320\300\1\xFF\206              8086,NOX86_64
+rm32                  \321\300\1\xFF\206              386,NOX86_64
+reg_fsgs              \1\x0F\7                        386,NOX86_64
+reg_sreg              \6                              8086,NOX86_64
+imm8                  \1\x6A\14                       286,NOX86_64
+imm16                 \320\1\x68\30                   286,NOX86_64
+imm32                 \321\1\x68\40                   386,NOX86_64
 
 [PUSHA,pushaX]
 (Ch_All, Ch_None, Ch_None)
-void                  \322\1\x60                      186
+void                  \323\1\x60                      186
 
 [PUSHAD,pushal]
 (Ch_All, Ch_None, Ch_None)
@@ -1896,7 +1899,7 @@ void                  \320\1\x60                      186
 
 [PUSHF]
 (Ch_RWESP, Ch_RFlags, Ch_None)
-void                  \322\1\x9C                      186
+void                  \323\1\x9C                      186
 
 [PUSHFD,pushfl]
 (Ch_RWESP, Ch_RFlags, Ch_None)
@@ -2026,7 +2029,7 @@ void                  \2\x0F\xAA                      PENT,SMM
 
 [SAHF]
 (Ch_WFlags, Ch_REAX, Ch_None)
-void                  \1\x9E                          8086
+void                  \1\x9E                          8086,NOX86_64
 
 [SAL,salX]
 (Ch_Mop2, Ch_Rop1, Ch_RWFlags)
@@ -2437,7 +2440,7 @@ reg32,reg32           \321\301\1\x0F\330\x40\110      P6
 
 [Jcc]
 (Ch_None, Ch_None, Ch_None)
-imm|near              \322\1\x0F\330\x80\64           386,PASS2
+imm|near              \323\1\x0F\330\x80\64           386,PASS2
 imm16|near            \320\1\x0F\330\x80\64           386,PASS2
 imm32|near            \321\1\x0F\330\x80\64           386,PASS2
 imm                   \330\x70\50                     8086
@@ -3404,25 +3407,21 @@ xmmreg,xmmreg		\3\xF3\x0F\x16\110		PRESCOTT,SSE3
 xmmreg,mem		\301\3\xF3\x0F\x12\110		PRESCOTT,SSE3
 xmmreg,xmmreg           \3\xF3\x0F\x12\110              PRESCOTT,SSE3
 
-;*****************************************************************************************
-; tell the i386 instruction table converter to stop here
-;!!!x86_64
-;
 ;
-; x86-64 instructions
+; GAS specific x86-64 instructions
 ;
 [MOVABS]
 (Ch_Wop2, Ch_Rop1, Ch_None)
 reg32,imm               \321\10\xB8\41                  X86_64
 
-;*****************************************************************************************
-; Insert i386 instructions only above the line ;!!!x86_64 !
-;*****************************************************************************************
-
-
 ;
 ; $Log$
-; Revision 1.8  2004-02-03 16:53:37  peter
+; Revision 1.9  2004-02-09 22:14:17  peter
+;   * more x86_64 parameter fixes
+;   * tparalocation.lochigh is now used to indicate if registerhigh
+;     is used and what the type is
+;
+; Revision 1.8  2004/02/03 16:53:37  peter
 ; *** empty log message ***
 ;
 ; Revision 1.7  2004/01/15 14:01:32  florian

+ 7 - 128
compiler/x86_64/cgcpu.pas

@@ -40,9 +40,9 @@ unit cgcpu;
         class function reg_cgsize(const reg: tregister): tcgsize; override;
         procedure g_save_all_registers(list : taasmoutput);override;
         procedure g_restore_all_registers(list : taasmoutput;const funcretparaloc:tparalocation);override;
-        procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);override;
       end;
 
+
   implementation
 
     uses
@@ -102,139 +102,18 @@ unit cgcpu;
         {$warning todo tcgx86_64.g_restore_all_registers}
       end;
 
-
-    procedure tcgx86_64.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);
-      var
-         ecxpushed : boolean;
-         helpsize : longint;
-         i : byte;
-         reg8,reg32 : tregister;
-         srcref,dstref : treference;
-         swap : boolean;
-
-{!!!
-         procedure maybepushecx;
-         begin
-           if not(R_ECX in rg.unusedregsint) then
-             begin
-               list.concat(Taicpu.Op_reg(A_PUSH,S_L,R_ECX));
-               ecxpushed:=true;
-             end
-           else rg.getexplicitregisterint(list,R_ECX);
-         end;
-}
-
-      begin
-{!!!
-         if (not loadref) and
-            ((len<=8) or
-             (not(cs_littlesize in aktglobalswitches ) and (len<=12))) then
-           begin
-              helpsize:=len shr 3;
-              rg.getexplicitregisterint(list,R_RDI);
-              dstref:=dest;
-              srcref:=source;
-              for i:=1 to helpsize do
-                begin
-                   a_load_ref_reg(list,OS_64,srcref,R_RDI);
-                   If (len=8) and delsource then
-                     reference_release(list,source);
-                   a_load_reg_ref(list,OS_64,R_RDI,dstref);
-                   inc(srcref.offset,8);
-                   inc(dstref.offset,8);
-                   dec(len,8);
-                end;
-              if len>1 then
-                begin
-                   a_load_ref_reg(list,OS_16,srcref,R_EDI);
-                   If (len =4) and delsource then
-                     reference_release(list,source);
-                   a_load_reg_ref(list,OS_16,R_EDI,dstref);
-                   inc(srcref.offset,4);
-                   inc(dstref.offset,4);
-                   dec(len,4);
-                end;
-              if len>1 then
-                begin
-                   a_load_ref_reg(list,OS_16,srcref,R_DI);
-                   If (len = 2) and delsource then
-                     reference_release(list,source);
-                   a_load_reg_ref(list,OS_16,R_DI,dstref);
-                   inc(srcref.offset,2);
-                   inc(dstref.offset,2);
-                   dec(len,2);
-                end;
-              if len>0 then
-                begin
-                   a_load_ref_reg(list,OS_16,srcref,R_DIL);
-                   a_load_reg_ref(list,OS_16,R_DIL,dstref);
-                end;
-              rg.ungetregisterint(list,R_RDI);
-           end
-         else
-           begin
-              rg.getexplicitregisterint(list,R_RDI);
-              a_loadaddr_ref_reg(list,dest,R_RDI);
-              list.concat(tai_regalloc.Alloc(R_RSI));
-              if loadref then
-                a_load_ref_reg(list,OS_ADDR,source,R_RSI)
-              else
-                begin
-                  a_loadaddr_ref_reg(list,source,R_RSI);
-                  if delsource then
-                    reference_release(list,source);
-                end;
-
-              list.concat(Taicpu.Op_none(A_CLD,S_NO));
-              ecxpushed:=false;
-              if cs_littlesize in aktglobalswitches  then
-                begin
-                   maybepushecx;
-                   a_load_const_reg(list,OS_INT,len,R_RCX);
-                   list.concat(Taicpu.Op_none(A_REP,S_NO));
-                   list.concat(Taicpu.Op_none(A_MOVSB,S_NO));
-                end
-              else
-                begin
-                   helpsize:=len shr 2;
-                   len:=len and 3;
-                   if helpsize>1 then
-                    begin
-                      maybepushecx;
-                      a_load_const_reg(list,OS_INT,helpsize,R_RCX);
-                      list.concat(Taicpu.Op_none(A_REP,S_NO));
-                    end;
-                   if helpsize>0 then
-                    list.concat(Taicpu.Op_none(A_MOVSD,S_NO));
-                   if len>1 then
-                     begin
-                        dec(len,2);
-                        list.concat(Taicpu.Op_none(A_MOVSW,S_NO));
-                     end;
-                   if len=1 then
-                     list.concat(Taicpu.Op_none(A_MOVSB,S_NO));
-                end;
-              rg.ungetregisterint(list,R_RDI);
-              list.concat(tai_regalloc.DeAlloc(R_RSI));
-              if ecxpushed then
-                list.concat(Taicpu.Op_reg(A_POP,S_L,R_RCX))
-              else
-                rg.ungetregisterint(list,R_RCX);
-
-              { loading SELF-reference again }
-              g_maybe_loadself(list);
-           end;
-         if delsource then
-          tg.ungetiftemp(list,source);
-}
-      end;
 begin
   cg:=tcgx86_64.create;
   cg64:=tcg64f64.create;
 end.
 {
   $Log$
-  Revision 1.10  2004-02-04 22:01:13  peter
+  Revision 1.11  2004-02-09 22:14:17  peter
+    * more x86_64 parameter fixes
+    * tparalocation.lochigh is now used to indicate if registerhigh
+      is used and what the type is
+
+  Revision 1.10  2004/02/04 22:01:13  peter
     * first try to get cpupara working for x86_64
 
   Revision 1.9  2004/01/14 23:39:05  florian

+ 7 - 2
compiler/x86_64/cpubase.inc

@@ -96,7 +96,7 @@ const
         such as in PIC code. The exact meaning is ABI specific. For
         further information look at GCC source : PIC_OFFSET_TABLE_REGNUM
       }
-      NR_PIC_OFFSET_REG = NR_EBX;
+      NR_PIC_OFFSET_REG = NR_RBX;
       { Results are returned in this register (both 32 and 64 bits }
       NR_FUNCTION_RETURN_REG = NR_RAX;
       RS_FUNCTION_RETURN_REG = RS_RAX;
@@ -136,7 +136,12 @@ const
 
 {
   $Log$
-  Revision 1.12  2004-02-05 18:28:37  peter
+  Revision 1.13  2004-02-09 22:14:17  peter
+    * more x86_64 parameter fixes
+    * tparalocation.lochigh is now used to indicate if registerhigh
+      is used and what the type is
+
+  Revision 1.12  2004/02/05 18:28:37  peter
     * x86_64 fixes for opsize
 
   Revision 1.11  2004/01/15 13:57:58  florian

+ 1 - 0
compiler/x86_64/x8664ats.inc

@@ -200,6 +200,7 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
 attsufINT,
 attsufINT,
 attsufINT,

+ 1 - 0
compiler/x86_64/x8664att.inc

@@ -199,6 +199,7 @@
 'movsb',
 'movsd',
 'movsl',
+'movsq',
 'movsw',
 'movs',
 'movz',

+ 1 - 0
compiler/x86_64/x8664int.inc

@@ -199,6 +199,7 @@
 'movsb',
 'movsd',
 'movsl',
+'movsq',
 'movsw',
 'movsx',
 'movzx',

+ 1 - 1
compiler/x86_64/x8664nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
-1653;
+1638;

+ 1 - 0
compiler/x86_64/x8664op.inc

@@ -199,6 +199,7 @@ A_MOVQ,
 A_MOVSB,
 A_MOVSD,
 A_MOVSL,
+A_MOVSQ,
 A_MOVSW,
 A_MOVSX,
 A_MOVZX,

+ 1 - 0
compiler/x86_64/x8664pro.inc

@@ -200,6 +200,7 @@
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_Wop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_Wop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_RWEAX, Ch_WEDX, Ch_WFlags)),

+ 43 - 148
compiler/x86_64/x8664tab.inc

@@ -795,21 +795,21 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_immediate,ot_none,ot_none);
-    code    : #210#1#232#52;
+    code    : #211#1#232#52;
     flags   : if_8086
   ),
   (
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_immediate or ot_near,ot_none,ot_none);
-    code    : #210#1#232#52;
+    code    : #211#1#232#52;
     flags   : if_8086
   ),
   (
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_immediate or ot_far,ot_none,ot_none);
-    code    : #210#1#154#28#31;
+    code    : #211#1#154#28#31;
     flags   : if_8086
   ),
   (
@@ -858,7 +858,7 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_immediate or ot_immediate,ot_none,ot_none);
-    code    : #210#1#154#29#24;
+    code    : #211#1#154#29#24;
     flags   : if_8086
   ),
   (
@@ -893,7 +893,7 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_memory or ot_far,ot_none,ot_none);
-    code    : #210#192#1#255#131;
+    code    : #211#192#1#255#131;
     flags   : if_8086
   ),
   (
@@ -914,7 +914,7 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_memory or ot_near,ot_none,ot_none);
-    code    : #210#192#1#255#130;
+    code    : #211#192#1#255#130;
     flags   : if_8086
   ),
   (
@@ -949,7 +949,7 @@
     opcode  : A_CALL;
     ops     : 1;
     optypes : (ot_memory,ot_none,ot_none);
-    code    : #210#192#1#255#130;
+    code    : #211#192#1#255#130;
     flags   : if_8086
   ),
   (
@@ -3259,7 +3259,7 @@
     opcode  : A_IRET;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#207;
+    code    : #211#1#207;
     flags   : if_8086
   ),
   (
@@ -3295,28 +3295,28 @@
     ops     : 1;
     optypes : (ot_immediate or ot_short,ot_none,ot_none);
     code    : #1#235#40;
-    flags   : if_8086
+    flags   : if_8086 or if_pass2
   ),
   (
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_immediate,ot_none,ot_none);
-    code    : #210#1#233#52;
+    code    : #211#1#233#52;
     flags   : if_8086 or if_pass2
   ),
   (
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_immediate or ot_near,ot_none,ot_none);
-    code    : #210#1#233#52;
+    code    : #211#1#233#52;
     flags   : if_8086 or if_pass2
   ),
   (
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_immediate or ot_far,ot_none,ot_none);
-    code    : #210#1#234#28#31;
-    flags   : if_8086
+    code    : #211#1#234#28#31;
+    flags   : if_8086 or if_pass2
   ),
   (
     opcode  : A_JMP;
@@ -3364,7 +3364,7 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_immediate or ot_immediate,ot_none,ot_none);
-    code    : #210#1#234#29#24;
+    code    : #211#1#234#29#24;
     flags   : if_8086
   ),
   (
@@ -3399,7 +3399,7 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_memory or ot_far,ot_none,ot_none);
-    code    : #210#192#1#255#133;
+    code    : #211#192#1#255#133;
     flags   : if_8086
   ),
   (
@@ -3420,7 +3420,7 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_memory or ot_near,ot_none,ot_none);
-    code    : #210#192#1#255#132;
+    code    : #211#192#1#255#132;
     flags   : if_8086
   ),
   (
@@ -3455,7 +3455,7 @@
     opcode  : A_JMP;
     ops     : 1;
     optypes : (ot_memory,ot_none,ot_none);
-    code    : #210#192#1#255#132;
+    code    : #211#192#1#255#132;
     flags   : if_8086
   ),
   (
@@ -3511,7 +3511,7 @@
     opcode  : A_LCALL;
     ops     : 1;
     optypes : (ot_memory or ot_far,ot_none,ot_none);
-    code    : #210#192#1#255#131;
+    code    : #211#192#1#255#131;
     flags   : if_8086
   ),
   (
@@ -3532,7 +3532,7 @@
     opcode  : A_LCALL;
     ops     : 1;
     optypes : (ot_memory or ot_near,ot_none,ot_none);
-    code    : #210#192#1#255#130;
+    code    : #211#192#1#255#130;
     flags   : if_8086
   ),
   (
@@ -3567,7 +3567,7 @@
     opcode  : A_LCALL;
     ops     : 1;
     optypes : (ot_memory,ot_none,ot_none);
-    code    : #210#192#1#255#130;
+    code    : #211#192#1#255#130;
     flags   : if_8086
   ),
   (
@@ -3686,7 +3686,7 @@
     opcode  : A_LJMP;
     ops     : 1;
     optypes : (ot_memory or ot_far,ot_none,ot_none);
-    code    : #210#192#1#255#133;
+    code    : #211#192#1#255#133;
     flags   : if_8086
   ),
   (
@@ -3707,7 +3707,7 @@
     opcode  : A_LJMP;
     ops     : 1;
     optypes : (ot_memory or ot_near,ot_none,ot_none);
-    code    : #210#192#1#255#132;
+    code    : #211#192#1#255#132;
     flags   : if_8086
   ),
   (
@@ -3742,7 +3742,7 @@
     opcode  : A_LJMP;
     ops     : 1;
     optypes : (ot_memory,ot_none,ot_none);
-    code    : #210#192#1#255#132;
+    code    : #211#192#1#255#132;
     flags   : if_8086
   ),
   (
@@ -4133,72 +4133,30 @@
   (
     opcode  : A_MOV;
     ops     : 2;
-    optypes : (ot_reg_al,ot_mem_offs,ot_none);
-    code    : #193#1#160#29;
-    flags   : if_8086 or if_sm
-  ),
-  (
-    opcode  : A_MOV;
-    ops     : 2;
-    optypes : (ot_reg_ax,ot_mem_offs,ot_none);
-    code    : #193#208#1#161#29;
-    flags   : if_8086 or if_sm
-  ),
-  (
-    opcode  : A_MOV;
-    ops     : 2;
-    optypes : (ot_reg_eax,ot_mem_offs,ot_none);
-    code    : #193#209#1#161#29;
-    flags   : if_386 or if_sm
-  ),
-  (
-    opcode  : A_MOV;
-    ops     : 2;
-    optypes : (ot_mem_offs,ot_reg_al,ot_none);
-    code    : #192#1#162#28;
-    flags   : if_8086 or if_sm
-  ),
-  (
-    opcode  : A_MOV;
-    ops     : 2;
-    optypes : (ot_mem_offs,ot_reg_ax,ot_none);
-    code    : #192#208#1#163#28;
-    flags   : if_8086 or if_sm
-  ),
-  (
-    opcode  : A_MOV;
-    ops     : 2;
-    optypes : (ot_mem_offs,ot_reg_eax,ot_none);
-    code    : #192#209#1#163#28;
-    flags   : if_386 or if_sm
-  ),
-  (
-    opcode  : A_MOV;
-    ops     : 2;
-    optypes : (ot_reg32,ot_reg_cr4,ot_none);
+    optypes : (ot_reg64,ot_reg_cr4,ot_none);
     code    : #2#15#32#132;
-    flags   : if_pent or if_priv
+    flags   : if_pent or if_priv or if_x86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
-    optypes : (ot_reg32,ot_reg_creg,ot_none);
+    optypes : (ot_reg64,ot_reg_creg,ot_none);
     code    : #2#15#32#65;
-    flags   : if_386 or if_priv
+    flags   : if_386 or if_priv or if_x86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
-    optypes : (ot_reg32,ot_reg_dreg,ot_none);
+    optypes : (ot_reg64,ot_reg_dreg,ot_none);
     code    : #2#15#33#65;
-    flags   : if_386 or if_priv
+    flags   : if_386 or if_priv or if_x86_64
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
-    optypes : (ot_reg32,ot_reg_treg,ot_none);
+    optypes : (ot_reg64,ot_reg_treg,ot_none);
     code    : #2#15#36#65;
-    flags   : if_386 or if_priv
+    flags   : if_386 or if_priv or if_x86_64
   ),
   (
     opcode  : A_MOV;
@@ -4536,6 +4494,13 @@
     code    : #209#1#165;
     flags   : if_386
   ),
+  (
+    opcode  : A_MOVSQ;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #210#1#165;
+    flags   : if_x86_64
+  ),
   (
     opcode  : A_MOVSW;
     ops     : 0;
@@ -5926,7 +5891,7 @@
     opcode  : A_POPA;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#97;
+    code    : #211#1#97;
     flags   : if_186
   ),
   (
@@ -5947,7 +5912,7 @@
     opcode  : A_POPF;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#157;
+    code    : #211#1#157;
     flags   : if_186
   ),
   (
@@ -6727,74 +6692,11 @@
     code    : #3#102#15#97#72;
     flags   : if_willamette or if_sse2
   ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_reg16,ot_none,ot_none);
-    code    : #208#8#80;
-    flags   : if_8086
-  ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_reg32,ot_none,ot_none);
-    code    : #209#8#80;
-    flags   : if_386
-  ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
-    code    : #208#192#1#255#134;
-    flags   : if_8086
-  ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
-    code    : #209#192#1#255#134;
-    flags   : if_386
-  ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_reg_fsgs,ot_none,ot_none);
-    code    : #1#15#7;
-    flags   : if_386
-  ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_reg_sreg,ot_none,ot_none);
-    code    : #6;
-    flags   : if_8086
-  ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_immediate or ot_bits8 or ot_signed,ot_none,ot_none);
-    code    : #1#106#12;
-    flags   : if_286
-  ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_immediate or ot_bits16,ot_none,ot_none);
-    code    : #208#1#104#24;
-    flags   : if_286
-  ),
-  (
-    opcode  : A_PUSH;
-    ops     : 1;
-    optypes : (ot_immediate or ot_bits32,ot_none,ot_none);
-    code    : #209#1#104#32;
-    flags   : if_386
-  ),
   (
     opcode  : A_PUSHA;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#96;
+    code    : #211#1#96;
     flags   : if_186
   ),
   (
@@ -6815,7 +6717,7 @@
     opcode  : A_PUSHF;
     ops     : 0;
     optypes : (ot_none,ot_none,ot_none);
-    code    : #210#1#156;
+    code    : #211#1#156;
     flags   : if_186
   ),
   (
@@ -7238,13 +7140,6 @@
     code    : #2#15#170;
     flags   : if_pent or if_smm
   ),
-  (
-    opcode  : A_SAHF;
-    ops     : 0;
-    optypes : (ot_none,ot_none,ot_none);
-    code    : #1#158;
-    flags   : if_8086
-  ),
   (
     opcode  : A_SAL;
     ops     : 2;
@@ -8894,7 +8789,7 @@
     opcode  : A_Jcc;
     ops     : 1;
     optypes : (ot_immediate or ot_near,ot_none,ot_none);
-    code    : #210#1#15#216#128#52;
+    code    : #211#1#15#216#128#52;
     flags   : if_386 or if_pass2
   ),
   (