Browse Source

+ support xgetbv instruction, resolves issue #29958

git-svn-id: trunk@33418 -
florian 9 years ago
parent
commit
406e3c4ac1

+ 1 - 0
.gitattributes

@@ -14997,6 +14997,7 @@ tests/webtbs/tw29893.pp svneol=native#text/pascal
 tests/webtbs/tw29912.pp svneol=native#text/plain
 tests/webtbs/tw29912.pp svneol=native#text/plain
 tests/webtbs/tw29923.pp svneol=native#text/plain
 tests/webtbs/tw29923.pp svneol=native#text/plain
 tests/webtbs/tw29930.pp svneol=native#text/plain
 tests/webtbs/tw29930.pp svneol=native#text/plain
+tests/webtbs/tw29958.pp svneol=native#text/pascal
 tests/webtbs/tw2998.pp svneol=native#text/plain
 tests/webtbs/tw2998.pp svneol=native#text/plain
 tests/webtbs/tw2999.pp svneol=native#text/plain
 tests/webtbs/tw2999.pp svneol=native#text/plain
 tests/webtbs/tw3004.pp svneol=native#text/plain
 tests/webtbs/tw3004.pp svneol=native#text/plain

+ 2 - 1
compiler/i386/i386att.inc

@@ -1033,5 +1033,6 @@
 'xend',
 'xend',
 'xtest',
 'xtest',
 'rdrand',
 'rdrand',
-'rdseed'
+'rdseed',
+'xgetbv'
 );
 );

+ 1 - 0
compiler/i386/i386atts.inc

@@ -1033,5 +1033,6 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
 attsufNONE
 attsufNONE
 );
 );

+ 2 - 1
compiler/i386/i386int.inc

@@ -1033,5 +1033,6 @@
 'xend',
 'xend',
 'xtest',
 'xtest',
 'rdrand',
 'rdrand',
-'rdseed'
+'rdseed',
+'xgetbv'
 );
 );

+ 1 - 1
compiler/i386/i386nop.inc

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

+ 2 - 1
compiler/i386/i386op.inc

@@ -1033,5 +1033,6 @@ A_XABORT,
 A_XEND,
 A_XEND,
 A_XTEST,
 A_XTEST,
 A_RDRAND,
 A_RDRAND,
-A_RDSEED
+A_RDSEED,
+A_XGETBV
 );
 );

+ 2 - 1
compiler/i386/i386prop.inc

@@ -1033,5 +1033,6 @@
 (Ch: (Ch_None, Ch_None, Ch_None)),
 (Ch: (Ch_None, Ch_None, Ch_None)),
 (Ch: (Ch_WFlags, Ch_None, Ch_None)),
 (Ch: (Ch_WFlags, Ch_None, Ch_None)),
 (Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
 (Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
-(Ch: (Ch_Wop1, Ch_WFlags, CH_None))
+(Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
+(Ch: (Ch_WEAX, Ch_WEDX, Ch_RECX))
 );
 );

+ 7 - 0
compiler/i386/i386tab.inc

@@ -13656,5 +13656,12 @@
     optypes : (ot_reg16 or ot_bits32 or ot_bits64,ot_none,ot_none,ot_none);
     optypes : (ot_reg16 or ot_bits32 or ot_bits64,ot_none,ot_none,ot_none);
     code    : #208#2#15#199#135;
     code    : #208#2#15#199#135;
     flags   : if_rand
     flags   : if_rand
+  ),
+  (
+    opcode  : A_XGETBV;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none,ot_none);
+    code    : #3#15#1#208;
+    flags   : if_xsave
   )
   )
 );
 );

+ 2 - 1
compiler/i8086/i8086att.inc

@@ -1047,5 +1047,6 @@
 'xend',
 'xend',
 'xtest',
 'xtest',
 'rdrand',
 'rdrand',
-'rdseed'
+'rdseed',
+'xgetbv'
 );
 );

+ 1 - 0
compiler/i8086/i8086atts.inc

@@ -1047,5 +1047,6 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
 attsufNONE
 attsufNONE
 );
 );

+ 2 - 1
compiler/i8086/i8086int.inc

@@ -1047,5 +1047,6 @@
 'xend',
 'xend',
 'xtest',
 'xtest',
 'rdrand',
 'rdrand',
-'rdseed'
+'rdseed',
+'xgetbv'
 );
 );

+ 1 - 1
compiler/i8086/i8086nop.inc

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

+ 2 - 1
compiler/i8086/i8086op.inc

@@ -1047,5 +1047,6 @@ A_XABORT,
 A_XEND,
 A_XEND,
 A_XTEST,
 A_XTEST,
 A_RDRAND,
 A_RDRAND,
-A_RDSEED
+A_RDSEED,
+A_XGETBV
 );
 );

+ 2 - 1
compiler/i8086/i8086prop.inc

@@ -1047,5 +1047,6 @@
 (Ch: (Ch_None, Ch_None, Ch_None)),
 (Ch: (Ch_None, Ch_None, Ch_None)),
 (Ch: (Ch_WFlags, Ch_None, Ch_None)),
 (Ch: (Ch_WFlags, Ch_None, Ch_None)),
 (Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
 (Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
-(Ch: (Ch_Wop1, Ch_WFlags, CH_None))
+(Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
+(Ch: (Ch_WEAX, Ch_WEDX, Ch_RECX))
 );
 );

+ 7 - 0
compiler/i8086/i8086tab.inc

@@ -13880,5 +13880,12 @@
     optypes : (ot_reg16 or ot_bits32 or ot_bits64,ot_none,ot_none,ot_none);
     optypes : (ot_reg16 or ot_bits32 or ot_bits64,ot_none,ot_none,ot_none);
     code    : #208#2#15#199#135;
     code    : #208#2#15#199#135;
     flags   : if_rand
     flags   : if_rand
+  ),
+  (
+    opcode  : A_XGETBV;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none,ot_none);
+    code    : #3#15#1#208;
+    flags   : if_xsave
   )
   )
 );
 );

+ 1 - 0
compiler/x86/aasmcpu.pas

@@ -449,6 +449,7 @@ implementation
        IF_FMA4   = $00200000;
        IF_FMA4   = $00200000;
        IF_TSX    = $00200000;
        IF_TSX    = $00200000;
        IF_RAND   = $00200000;
        IF_RAND   = $00200000;
+       IF_XSAVE  = $00200000;
 
 
        IF_PLEVEL = $0F000000;  { mask for processor level }
        IF_PLEVEL = $0F000000;  { mask for processor level }
        IF_8086   = $00000000;  { 8086 instruction  }
        IF_8086   = $00000000;  { 8086 instruction  }

+ 8 - 0
compiler/x86/x86ins.dat

@@ -5410,3 +5410,11 @@ reg16|32|64                          \320\2\x0F\xC7\206                   RAND
 [RDSEED]
 [RDSEED]
 (Ch_Wop1, Ch_WFlags, CH_None)
 (Ch_Wop1, Ch_WFlags, CH_None)
 reg16|32|64                          \320\2\x0F\xC7\207                   RAND
 reg16|32|64                          \320\2\x0F\xC7\207                   RAND
+
+;*******************************************************************************
+;********** XSAVE **************************************************************
+;*******************************************************************************
+[XGETBV]
+(Ch_WEAX, Ch_WEDX, Ch_RECX)
+void                  \3\x0F\x01\xD0                                      XSAVE
+

+ 1 - 0
compiler/x86_64/x8664ats.inc

@@ -1027,5 +1027,6 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
 attsufNONE
 attsufNONE
 );
 );

+ 2 - 1
compiler/x86_64/x8664att.inc

@@ -1027,5 +1027,6 @@
 'xend',
 'xend',
 'xtest',
 'xtest',
 'rdrand',
 'rdrand',
-'rdseed'
+'rdseed',
+'xgetbv'
 );
 );

+ 2 - 1
compiler/x86_64/x8664int.inc

@@ -1027,5 +1027,6 @@
 'xend',
 'xend',
 'xtest',
 'xtest',
 'rdrand',
 'rdrand',
-'rdseed'
+'rdseed',
+'xgetbv'
 );
 );

+ 1 - 1
compiler/x86_64/x8664nop.inc

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

+ 2 - 1
compiler/x86_64/x8664op.inc

@@ -1027,5 +1027,6 @@ A_XABORT,
 A_XEND,
 A_XEND,
 A_XTEST,
 A_XTEST,
 A_RDRAND,
 A_RDRAND,
-A_RDSEED
+A_RDSEED,
+A_XGETBV
 );
 );

+ 2 - 1
compiler/x86_64/x8664pro.inc

@@ -1027,5 +1027,6 @@
 (Ch: (Ch_None, Ch_None, Ch_None)),
 (Ch: (Ch_None, Ch_None, Ch_None)),
 (Ch: (Ch_WFlags, Ch_None, Ch_None)),
 (Ch: (Ch_WFlags, Ch_None, Ch_None)),
 (Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
 (Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
-(Ch: (Ch_Wop1, Ch_WFlags, CH_None))
+(Ch: (Ch_Wop1, Ch_WFlags, CH_None)),
+(Ch: (Ch_WEAX, Ch_WEDX, Ch_RECX))
 );
 );

+ 7 - 0
compiler/x86_64/x8664tab.inc

@@ -13803,5 +13803,12 @@
     optypes : (ot_reg16 or ot_bits32 or ot_bits64,ot_none,ot_none,ot_none);
     optypes : (ot_reg16 or ot_bits32 or ot_bits64,ot_none,ot_none,ot_none);
     code    : #208#2#15#199#135;
     code    : #208#2#15#199#135;
     flags   : if_rand
     flags   : if_rand
+  ),
+  (
+    opcode  : A_XGETBV;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none,ot_none);
+    code    : #3#15#1#208;
+    flags   : if_xsave
   )
   )
 );
 );

+ 25 - 0
tests/webtbs/tw29958.pp

@@ -0,0 +1,25 @@
+{ %CPU=i386,x86_64 }
+{ %norun }
+
+const
+  expected_code : array[0..2] of byte = ($0f,$01,$D0);
+
+procedure proc;assembler;nostackframe;
+  asm
+    xgetbv
+  end;
+
+
+var
+  P : pointer;
+  i : integer;
+
+begin
+  for i:=0 to high(expected_code) do
+    if (pbyte(@proc)+i)^<>expected_code[i] then
+      begin
+        writeln('Error at pos ',i,'. Expected $',hexstr(expected_code[i],2),' got $',hexstr((pbyte(@proc)+i)^,2));
+        halt(1);
+      end;
+  writeln('ok');
+end.