Browse Source

summary avx-tests

git-svn-id: branches/tg74/avx1@22659 -
tg74 13 years ago
parent
commit
486f6fe380
1 changed files with 52 additions and 19 deletions
  1. 52 19
      tests/test/tasm7.pp

+ 52 - 19
tests/test/tasm7.pp

@@ -1,24 +1,57 @@
-{ %CPU=i386 }
+{ %CPU=i386,x86_64 }
 
-{$asmmode att}
-var
-  test: array[0..2] of longint;
-
-function proc: longint; assembler;
+// (Almost) every of these instructions use a high register and thus generate REX.
+{$asmmode intel}
+procedure avxtest; assembler; nostackframe;
 asm
-     call   .L1
-.L1:
-     pop    %eax
-     movl   test-.L1(%eax),%eax
-// This should also work (but it doesn't due to bugs in asmreader):
-//   movl   test-.L1+8(%eax),%eax     
+    VADDPD         XMM0, XMM1, [RAX] + $100
+    VADDPD         YMM2, YMM3, [RAX] + $100
+
+    VBLENDPD       XMM2, XMM5, XMM7, $02
+    VBLENDPD       YMM2, YMM5, YMM7, $0F
+
+    VBLENDVPS      XMM2, XMM5, XMM7, XMM4
+    VBLENDVPS      YMM0, YMM1, YMM2, YMM5
+
+    VBROADCASTSD   YMM0, [RAX]
+
+    VPEXTRB         EAX, XMM0, $00
+
+    VPINSRD        XMM7, XMM1, EAX, $03
+
+    VZEROALL
+
+end;
+
+
+const
+  avxtest_expected : array[0..59] of byte = (
+  $C5,$F1,$58,$80,$00,$01,$00,$00,
+  $C5,$E5,$58,$90,$00,$01,$00,$00,
+  $C4,$E3,$51,$0D,$D7,$02,
+  $C4,$E3,$55,$0D,$D7,$0F,
+  $C4,$E3,$51,$4A,$D7,$40,
+  $C4,$E3,$75,$4A,$C2,$50,
+  $C4,$E2,$7D,$19,$00,
+  $C4,$E3,$79,$14,$C0,$00,
+  $C4,$E3,$71,$22,$F8,$03,
+  $C5,$FC,$77);
+
+
+
+procedure check(const id: string; const expected: array of byte; p: pointer);
+var
+  i : longint;
+begin
+  for i:=0 to high(expected) do
+    if expected[i]<>pbyte(p)[i] then
+      begin
+        writeln(id, ' mismatch at offset $',hexstr(i,4), ', expected=$',hexstr(expected[i],2),' actual=$',hexstr(pbyte(p)[i],2));
+        halt(1);
+      end;
 end;
 
 begin
-  test[0]:=5555;
-  test[1]:=6666;
-  test[2]:=7777;
-  if proc<>5555 then
-    Halt(1);
-  Halt(0);  
-end.
+  check('generic', avxtest_expected, @avxtest);
+  writeln('ok');
+end.