Add instruction tests for the LFENCE/MFENCE/SFENCE instructions.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2523 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/none/tests/gen_insn_test.pl b/none/tests/gen_insn_test.pl
index 395f627..6391c73 100644
--- a/none/tests/gen_insn_test.pl
+++ b/none/tests/gen_insn_test.pl
@@ -165,12 +165,17 @@
my $args;
my $results;
- if (/^(\S+)\s+(?:(\S+(?:\s+\S+)*)\s+:\s+)?((?:\S+\s+)*)=>\s+(\S+(?:\s+\S+)*)$/)
+ if (/^(\S+)\s+(?:(\S+(?:\s+\S+)*)\s+:\s+)?((?:\S+\s+)*?)(?:=>\s+(\S+(?:\s+\S+)*))?$/)
{
$insn = $1;
$presets = $2 || "";
- $args = $3;
- $results = $4;
+ $args = $3 || "";
+ $results = $4 || "";
+
+# print STDERR "insn: $insn\n";
+# print STDERR "presets: $presets\n";
+# print STDERR "args: $args\n";
+# print STDERR "results: $results\n";
}
else
{
@@ -857,82 +862,90 @@
print qq| \);\n|;
print qq|\n|;
- print qq| if \(|;
-
- $prefix = "";
-
- foreach my $result (@results)
+ if (@results)
{
- my $type = $result->{type};
- my $subtype = $result->{subtype};
- my $suffix = $SubTypeSuffixes{$subtype};
- my @values = @{$result->{values}};
-
- if ($type eq "eflags")
+ print qq| if \(|;
+
+ $prefix = "";
+
+ foreach my $result (@results)
{
- print qq|${prefix}\($result->{name}.ud[0] & $values[0]UL\) == $values[1]UL|;
- }
- elsif ($type =~ /^fpu[cs]w$/)
- {
- print qq|${prefix}\($result->{name}.uw[0] & $values[0]\) == $values[1]|;
- }
- else
- {
- foreach my $value (0 .. $#values)
+ my $type = $result->{type};
+ my $subtype = $result->{subtype};
+ my $suffix = $SubTypeSuffixes{$subtype};
+ my @values = @{$result->{values}};
+
+ if ($type eq "eflags")
{
- if ($subtype eq "ps")
+ print qq|${prefix}\($result->{name}.ud[0] & $values[0]UL\) == $values[1]UL|;
+ }
+ elsif ($type =~ /^fpu[cs]w$/)
+ {
+ print qq|${prefix}\($result->{name}.uw[0] & $values[0]\) == $values[1]|;
+ }
+ else
+ {
+ foreach my $value (0 .. $#values)
{
- print qq|${prefix}eq_float($result->{name}.$subtype\[$value\], $values[$value]$suffix)|;
+ if ($subtype eq "ps")
+ {
+ print qq|${prefix}eq_float($result->{name}.$subtype\[$value\], $values[$value]$suffix)|;
+ }
+ elsif ($subtype eq "pd")
+ {
+ print qq|${prefix}eq_double($result->{name}.$subtype\[$value\], $values[$value]$suffix)|;
+ }
+ else
+ {
+ print qq|${prefix}$result->{name}.$subtype\[$value\] == $values[$value]$suffix|;
+ }
+
+ $prefix = " && ";
}
- elsif ($subtype eq "pd")
+ }
+
+ $prefix = " &&\n ";
+ }
+
+ print qq| \)\n|;
+ print qq| \{\n|;
+ print qq| printf("$test ... ok\\n");\n|;
+ print qq| \}\n|;
+ print qq| else\n|;
+ print qq| \{\n|;
+ print qq| printf("$test ... not ok\\n");\n|;
+
+ foreach my $result (@results)
+ {
+ my $type = $result->{type};
+ my $subtype = $result->{subtype};
+ my $suffix = $SubTypeSuffixes{$subtype};
+ my @values = @{$result->{values}};
+
+ if ($type eq "eflags")
+ {
+ print qq| printf(" eflags & 0x%lx = 0x%lx (expected 0x%lx)\\n", $values[0]UL, $result->{name}.ud\[0\] & $values[0]UL, $values[1]UL);\n|;
+ }
+ elsif ($type =~ /^fpu[cs]w$/)
+ {
+ print qq| printf(" $type & 0x%x = 0x%x (expected 0x%x)\\n", $values[0], $result->{name}.uw\[0\] & $values[0], $values[1]);\n|;
+ }
+ else
+ {
+ foreach my $value (0 .. $#values)
{
- print qq|${prefix}eq_double($result->{name}.$subtype\[$value\], $values[$value]$suffix)|;
+ print qq| printf(" $result->{name}.$subtype\[$value\] = $SubTypeFormats{$subtype} (expected $SubTypeFormats{$subtype})\\n", $result->{name}.$subtype\[$value\], $values[$value]$suffix);\n|;
}
- else
- {
- print qq|${prefix}$result->{name}.$subtype\[$value\] == $values[$value]$suffix|;
- }
-
- $prefix = " && ";
}
}
- $prefix = " &&\n ";
+ print qq| \}\n|;
}
-
- print qq| \)\n|;
- print qq| \{\n|;
- print qq| printf("$test ... ok\\n");\n|;
- print qq| \}\n|;
- print qq| else\n|;
- print qq| \{\n|;
- print qq| printf("$test ... not ok\\n");\n|;
-
- foreach my $result (@results)
+ else
{
- my $type = $result->{type};
- my $subtype = $result->{subtype};
- my $suffix = $SubTypeSuffixes{$subtype};
- my @values = @{$result->{values}};
-
- if ($type eq "eflags")
- {
- print qq| printf(" eflags & 0x%lx = 0x%lx (expected 0x%lx)\\n", $values[0]UL, $result->{name}.ud\[0\] & $values[0]UL, $values[1]UL);\n|;
- }
- elsif ($type =~ /^fpu[cs]w$/)
- {
- print qq| printf(" $type & 0x%x = 0x%x (expected 0x%x)\\n", $values[0], $result->{name}.uw\[0\] & $values[0], $values[1]);\n|;
- }
- else
- {
- foreach my $value (0 .. $#values)
- {
- print qq| printf(" $result->{name}.$subtype\[$value\] = $SubTypeFormats{$subtype} (expected $SubTypeFormats{$subtype})\\n", $result->{name}.$subtype\[$value\], $values[$value]$suffix);\n|;
- }
- }
+ print qq| printf("$test ... ok\\n");\n|;
}
-
- print qq| \}\n|;
+
print qq| \}\n|;
print qq| else\n|;
print qq| \{\n|;
diff --git a/none/tests/insn_mmxext.def b/none/tests/insn_mmxext.def
index fd07f87..f80313c 100644
--- a/none/tests/insn_mmxext.def
+++ b/none/tests/insn_mmxext.def
@@ -26,3 +26,4 @@
psadbw m64.ub[1,2,3,4,5,6,7,8] mm.ub[8,7,6,5,4,3,2,1] => 1.sw[32,0,0,0]
pshufw imm8[0x1b] mm.sw[11,22,33,44] mm.sw[0,0,0,0] => 2.sw[44,33,22,11]
pshufw imm8[0x1b] m64.sw[11,22,33,44] mm.sw[0,0,0,0] => 2.sw[44,33,22,11]
+sfence
diff --git a/none/tests/insn_mmxext.stdout.exp b/none/tests/insn_mmxext.stdout.exp
index 631f793..23b2e55 100644
--- a/none/tests/insn_mmxext.stdout.exp
+++ b/none/tests/insn_mmxext.stdout.exp
@@ -26,3 +26,4 @@
psadbw_2 ... ok
pshufw_1 ... ok
pshufw_2 ... ok
+sfence_1 ... ok
diff --git a/none/tests/insn_sse.def b/none/tests/insn_sse.def
index b3d9edc..f2b3ea5 100644
--- a/none/tests/insn_sse.def
+++ b/none/tests/insn_sse.def
@@ -117,6 +117,7 @@
rsqrtps m128.ps[4.0,16.0,25.0,64.0] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.499878,0.249939,0.199982,0.124969]
rsqrtss xmm.ps[16.0,5.55,6.66,7.77] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.249939,2.22,3.33,4.44]
rsqrtss m128.ps[16.0,5.55,6.66,7.77] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.249939,2.22,3.33,4.44]
+sfence
shufps imm8[0xe4] xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[12.34,56.78,43.21,87.65] => 2.ps[12.34,56.78,43.21,87.65]
shufps imm8[0xb1] m128.ps[12.34,56.78,43.21,87.65] xmm.ps[12.34,56.78,43.21,87.65] => 2.ps[56.78,12.34,87.65,43.21]
sqrtps xmm.ps[16.0,25.0,36.0,49.0] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[4.0,5.0,6.0,7.0]
diff --git a/none/tests/insn_sse.stdout.exp b/none/tests/insn_sse.stdout.exp
index c9ae0f1..f15bd81 100644
--- a/none/tests/insn_sse.stdout.exp
+++ b/none/tests/insn_sse.stdout.exp
@@ -117,6 +117,7 @@
rsqrtps_2 ... ok
rsqrtss_1 ... ok
rsqrtss_2 ... ok
+sfence_1 ... ok
shufps_1 ... ok
shufps_2 ... ok
sqrtps_1 ... ok
diff --git a/none/tests/insn_sse2.def b/none/tests/insn_sse2.def
index 442fff3..515c35d 100644
--- a/none/tests/insn_sse2.def
+++ b/none/tests/insn_sse2.def
@@ -72,10 +72,12 @@
divpd m128.pd[2.0,3.0] xmm.pd[24.68,3.69] => 1.pd[12.34,1.23]
divsd xmm.pd[2.0,3.0] xmm.pd[24.68,3.69] => 1.pd[12.34,3.69]
divsd m128.pd[2.0,3.0] xmm.pd[24.68,3.69] => 1.pd[12.34,3.69]
+lfence
maxpd xmm.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[55.555,44.444]
maxpd m128.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[55.555,44.444]
maxsd xmm.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[55.555,33.333]
maxsd m128.pd[44.444,22.222] xmm.pd[33.333,55.555] => 1.pd[44.444,55.555]
+mfence
minpd xmm.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[22.222,33.333]
minpd m128.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[22.222,33.333]
minsd xmm.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[22.222,33.333]
diff --git a/none/tests/insn_sse2.stdout.exp b/none/tests/insn_sse2.stdout.exp
index 53340e7..9c24f72 100644
--- a/none/tests/insn_sse2.stdout.exp
+++ b/none/tests/insn_sse2.stdout.exp
@@ -72,10 +72,12 @@
divpd_2 ... ok
divsd_1 ... ok
divsd_2 ... ok
+lfence_1 ... ok
maxpd_1 ... ok
maxpd_2 ... ok
maxsd_1 ... ok
maxsd_2 ... ok
+mfence_1 ... ok
minpd_1 ... ok
minpd_2 ... ok
minsd_1 ... ok