aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/config/tc-i386.c46
-rw-r--r--gas/testsuite/ChangeLog6
-rw-r--r--gas/testsuite/gas/i386/i386.exp2
-rw-r--r--gas/testsuite/gas/i386/immed32.d50
-rw-r--r--gas/testsuite/gas/i386/immed32.s47
-rw-r--r--gas/testsuite/gas/i386/immed64.d59
-rw-r--r--gas/testsuite/gas/i386/immed64.s56
8 files changed, 256 insertions, 16 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 8a6d0c0..366981c 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-26 Jan Beulich <jbeulich@novell.com>
+
+ * config/tc-i386.c (optimize_imm): Calculate candidate immediates
+ mask from guessed suffix, but mask out other immediate types only
+ if at least on candidate is valid for the insn.
+
2005-07-25 DJ Delorie <dj@redhat.com>
* config/tc-m32c.c (md_cgen_lookup_reloc): Add 8 bit operands.
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index df3a35b..139e403 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2087,22 +2087,36 @@ optimize_imm ()
/* Symbols and expressions. */
default:
- /* Convert symbolic operand to proper sizes for matching. */
- switch (guess_suffix)
- {
- case QWORD_MNEM_SUFFIX:
- i.types[op] &= Imm64 | Imm32S;
- break;
- case LONG_MNEM_SUFFIX:
- i.types[op] &= Imm32;
- break;
- case WORD_MNEM_SUFFIX:
- i.types[op] &= Imm16;
- break;
- case BYTE_MNEM_SUFFIX:
- i.types[op] &= Imm8 | Imm8S;
- break;
- }
+ /* Convert symbolic operand to proper sizes for matching, but don't
+ prevent matching a set of insns that only supports sizes other
+ than those matching the insn suffix. */
+ {
+ unsigned int mask, allowed = 0;
+ const template *t;
+
+ for (t = current_templates->start; t < current_templates->end; ++t)
+ allowed |= t->operand_types[op];
+ switch (guess_suffix)
+ {
+ case QWORD_MNEM_SUFFIX:
+ mask = Imm64 | Imm32S;
+ break;
+ case LONG_MNEM_SUFFIX:
+ mask = Imm32;
+ break;
+ case WORD_MNEM_SUFFIX:
+ mask = Imm16;
+ break;
+ case BYTE_MNEM_SUFFIX:
+ mask = Imm8;
+ break;
+ default:
+ mask = 0;
+ break;
+ }
+ if (mask & allowed)
+ i.types[op] &= mask;
+ }
break;
}
}
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index a4f02c7..892c77a 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-26 Jan Beulich <jbeulich@novell.com>
+
+ * gas/i386/immed32.[sd]: New.
+ * gas/i386/immed64.[sd]: New.
+ * gas/i386/i386.exp: Run new tests.
+
2005-07-21 Paul Brook <paul@codesourcery.com>
* gas/arm/thumb32.s: Add tests for [pc, #imm] addressing modes.
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 6e0340d..8981092 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -62,6 +62,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "sib"
run_dump_test "vmx"
run_dump_test "suffix"
+ run_dump_test "immed32"
if {![istarget "*-*-aix*"]
&& (![is_elf_format] || [istarget "*-*-linux*"]
@@ -135,6 +136,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
run_dump_test "x86-64-branch"
run_dump_test "svme64"
run_dump_test "x86-64-vmx"
+ run_dump_test "immed64"
# For ELF targets verify that @unwind works.
if { ([istarget "*-*-elf*"] || [istarget "*-*-linux*"]
diff --git a/gas/testsuite/gas/i386/immed32.d b/gas/testsuite/gas/i386/immed32.d
new file mode 100644
index 0000000..3d308a8
--- /dev/null
+++ b/gas/testsuite/gas/i386/immed32.d
@@ -0,0 +1,50 @@
+#objdump: -dw
+#name: i386 immed
+
+.*: +file format .*
+
+Disassembly of section \.text:
+
+0+000 <_start>:
+[ ]*[0-9a-fA-F]+:[ ]+ff 50 04[ ]+calll? +\*0x4\(%eax\)
+[ ]*[0-9a-fA-F]+:[ ]+ff 90 08 00 00 00[ ]+calll? +\*0x8\(%eax\)
+[ ]*[0-9a-fA-F]+:[ ]+ff 90 00 00 00 00[ ]+calll? +\*0x0\(%eax\)
+[ ]*[0-9a-fA-F]+:[ ]+67 ff 57 04[ ]+(addr16 )?calll? +\*4\(%bx\)
+[ ]*[0-9a-fA-F]+:[ ]+67 ff 97 08 00[ ]+(addr16 )?calll? +\*8\(%bx\)
+[ ]*[0-9a-fA-F]+:[ ]+67 ff 97 00 00[ ]+(addr16 )?calll? +\*0\(%bx\)
+[ ]*[0-9a-fA-F]+:[ ]+b0 04[ ]+movb? +\$0x4,%al
+[ ]*[0-9a-fA-F]+:[ ]+b0 08[ ]+movb? +\$0x8,%al
+[ ]*[0-9a-fA-F]+:[ ]+b0 00[ ]+movb? +\$0x0,%al
+[ ]*[0-9a-fA-F]+:[ ]+66 b8 04 00[ ]+movw? +\$0x4,%ax
+[ ]*[0-9a-fA-F]+:[ ]+66 b8 08 00[ ]+movw? +\$0x8,%ax
+[ ]*[0-9a-fA-F]+:[ ]+66 b8 00 00[ ]+movw? +\$0x0,%ax
+[ ]*[0-9a-fA-F]+:[ ]+b8 04 00 00 00[ ]+movl? +\$0x4,%eax
+[ ]*[0-9a-fA-F]+:[ ]+b8 08 00 00 00[ ]+movl? +\$0x8,%eax
+[ ]*[0-9a-fA-F]+:[ ]+b8 00 00 00 00[ ]+movl? +\$0x0,%eax
+[ ]*[0-9a-fA-F]+:[ ]+04 04[ ]+addb? +\$0x4,%al
+[ ]*[0-9a-fA-F]+:[ ]+04 08[ ]+addb? +\$0x8,%al
+[ ]*[0-9a-fA-F]+:[ ]+04 00[ ]+addb? +\$0x0,%al
+[ ]*[0-9a-fA-F]+:[ ]+66 83 c0 04[ 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-fA-F]+:[ ]+e5 04[ ]+inl? +\$0x4,%eax
+[ ]*[0-9a-fA-F]+:[ ]+e5 08[ ]+inl? +\$0x8,%eax
+[ ]*[0-9a-fA-F]+:[ ]+e5 00[ ]+inl? +\$0x0,%eax
diff --git a/gas/testsuite/gas/i386/immed32.s b/gas/testsuite/gas/i386/immed32.s
new file mode 100644
index 0000000..a0b058f
--- /dev/null
+++ b/gas/testsuite/gas/i386/immed32.s
@@ -0,0 +1,47 @@
+ .equiv early, 4
+
+_start:
+ calll *early(%eax)
+ calll *late(%eax)
+ calll *xtrn(%eax)
+ calll *early(%bx)
+ calll *late(%bx)
+ calll *xtrn(%bx)
+ movb $early, %al
+ movb $late, %al
+ movb $xtrn, %al
+ movw $early, %ax
+ movw $late, %ax
+ movw $xtrn, %ax
+ movl $early, %eax
+ movl $late, %eax
+ movl $xtrn, %eax
+ addb $early, %al
+ addb $late, %al
+ addb $xtrn, %al
+ addw $early, %ax
+ addw $late, %ax
+ addw $xtrn, %ax
+ addl $early, %eax
+ addl $late, %eax
+ addl $xtrn, %eax
+ shlb $early, %al
+ shlb $late, %al
+ shlb $xtrn, %al
+ shlw $early, %ax
+ shlw $late, %ax
+ shlw $xtrn, %ax
+ shll $early, %eax
+ shll $late, %eax
+ shll $xtrn, %eax
+ inb $early, %al
+ inb $late, %al
+ inb $xtrn, %al
+ inw $early, %ax
+ inw $late, %ax
+ inw $xtrn, %ax
+ inl $early, %eax
+ inl $late, %eax
+ inl $xtrn, %eax
+
+ .equiv late, 8
diff --git a/gas/testsuite/gas/i386/immed64.d b/gas/testsuite/gas/i386/immed64.d
new file mode 100644
index 0000000..c2ab324
--- /dev/null
+++ b/gas/testsuite/gas/i386/immed64.d
@@ -0,0 +1,59 @@
+#objdump: -dw
+#name: x86-64 immed
+
+.*: +file format .*
+
+Disassembly of section \.text:
+
+0+000 <_start>:
+[ ]*[0-9a-fA-F]+:[ ]+ff 50 04[ ]+callq? +\*0x4\(%rax\)
+[ ]*[0-9a-fA-F]+:[ ]+ff 90 08 00 00 00[ ]+callq? +\*0x8\(%rax\)
+[ ]*[0-9a-fA-F]+:[ ]+ff 90 00 00 00 00[ ]+callq? +\*0x0\(%rax\)
+[ ]*[0-9a-fA-F]+:[ ]+67 ff 50 04[ ]+(addr32 )?callq? +\*0x4\(%eax\)
+[ ]*[0-9a-fA-F]+:[ ]+67 ff 90 08 00 00 00[ ]+(addr32 )?callq? +\*0x8\(%eax\)
+[ ]*[0-9a-fA-F]+:[ ]+67 ff 90 00 00 00 00[ ]+(addr32 )?callq? +\*0x0\(%eax\)
+[ ]*[0-9a-fA-F]+:[ ]+b0 04[ ]+movb? +\$0x4,%al
+[ ]*[0-9a-fA-F]+:[ ]+b0 08[ ]+movb? +\$0x8,%al
+[ ]*[0-9a-fA-F]+:[ ]+b0 00[ ]+movb? +\$0x0,%al
+[ ]*[0-9a-fA-F]+:[ ]+66 b8 04 00[ ]+movw? +\$0x4,%ax
+[ ]*[0-9a-fA-F]+:[ ]+66 b8 08 00[ ]+movw? +\$0x8,%ax
+[ ]*[0-9a-fA-F]+:[ ]+66 b8 00 00[ ]+movw? +\$0x0,%ax
+[ ]*[0-9a-fA-F]+:[ ]+b8 04 00 00 00[ ]+movl? +\$0x4,%eax
+[ ]*[0-9a-fA-F]+:[ ]+b8 08 00 00 00[ ]+movl? +\$0x8,%eax
+[ ]*[0-9a-fA-F]+:[ ]+b8 00 00 00 00[ ]+movl? +\$0x0,%eax
+[ ]*[0-9a-fA-F]+:[ ]+48 b8 04 00 00 00 00 00 00 00[ ]+movq? +\$0x4,%rax
+[ ]*[0-9a-fA-F]+:[ ]+48 b8 08 00 00 00 00 00 00 00[ ]+movq? +\$0x8,%rax
+[ ]*[0-9a-fA-F]+:[ ]+48 b8 00 00 00 00 00 00 00 00[ ]+movq? +\$0x0,%rax
+[ ]*[0-9a-fA-F]+:[ ]+04 04[ ]+addb? +\$0x4,%al
+[ ]*[0-9a-fA-F]+:[ ]+04 08[ ]+addb? +\$0x8,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[ ]*[0-9a-fA-F]+:[ ]+48 c1 e0 08[ ]+shlq? +\$0x8,%rax
+[ ]*[0-9a-fA-F]+:[ ]+48 c1 e0 00[ ]+shlq? +\$0x0,%rax
+[ ]*[0-9a-fA-F]+:[ ]+e4 04[ ]+inb? +\$0x4,%al
+[ ]*[0-9a-fA-F]+:[ ]+e4 08[ ]+inb? +\$0x8,%al
+[ ]*[0-9a-fA-F]+:[ ]+e4 00[ ]+inb? +\$0x0,%al
+[ ]*[0-9a-fA-F]+:[ ]+66 e5 04[ ]+inw? +\$0x4,%ax
+[ ]*[0-9a-fA-F]+:[ ]+66 e5 08[ ]+inw? +\$0x8,%ax
+[ ]*[0-9a-fA-F]+:[ ]+66 e5 00[ ]+inw? +\$0x0,%ax
+[ ]*[0-9a-fA-F]+:[ ]+e5 04[ ]+inl? +\$0x4,%eax
+[ ]*[0-9a-fA-F]+:[ ]+e5 08[ ]+inl? +\$0x8,%eax
+[ ]*[0-9a-fA-F]+:[ ]+e5 00[ ]+inl? +\$0x0,%eax
diff --git a/gas/testsuite/gas/i386/immed64.s b/gas/testsuite/gas/i386/immed64.s
new file mode 100644
index 0000000..4e68701
--- /dev/null
+++ b/gas/testsuite/gas/i386/immed64.s
@@ -0,0 +1,56 @@
+ .equiv early, 4
+
+_start:
+ callq *early(%rax)
+ callq *late(%rax)
+ callq *xtrn(%rax)
+ callq *early(%eax)
+ callq *late(%eax)
+ callq *xtrn(%eax)
+ movb $early, %al
+ movb $late, %al
+ movb $xtrn, %al
+ movw $early, %ax
+ movw $late, %ax
+ movw $xtrn, %ax
+ movl $early, %eax
+ movl $late, %eax
+ movl $xtrn, %eax
+ movabsq $early, %rax
+ movabsq $late, %rax
+ movabsq $xtrn, %rax
+ addb $early, %al
+ addb $late, %al
+ addb $xtrn, %al
+ addw $early, %ax
+ addw $late, %ax
+ addw $xtrn, %ax
+ addl $early, %eax
+ addl $late, %eax
+ addl $xtrn, %eax
+ addq $early, %rax
+ addq $late, %rax
+ addq $xtrn, %rax
+ shlb $early, %al
+ shlb $late, %al
+ shlb $xtrn, %al
+ shlw $early, %ax
+ shlw $late, %ax
+ shlw $xtrn, %ax
+ shll $early, %eax
+ shll $late, %eax
+ shll $xtrn, %eax
+ shlq $early, %rax
+ shlq $late, %rax
+ shlq $xtrn, %rax
+ inb $early, %al
+ inb $late, %al
+ inb $xtrn, %al
+ inw $early, %ax
+ inw $late, %ax
+ inw $xtrn, %ax
+ inl $early, %eax
+ inl $late, %eax
+ inl $xtrn, %eax
+
+ .equiv late, 8