public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] LoongArch: gas: add support using constant variable in instructions.
@ 2022-08-22  2:25 liu & zhensong
  0 siblings, 0 replies; only message in thread
From: liu & zhensong @ 2022-08-22  2:25 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7ec249249cd4d1a31bdb9318dba7510f33d866df

commit 7ec249249cd4d1a31bdb9318dba7510f33d866df
Author: tangxiaolin <tangxiaolin@loongson.cn>
Date:   Wed Aug 17 15:12:43 2022 +0800

    LoongArch: gas: add support using constant variable in instructions.
    
            Instructions that can load immediate support using constant
            variable like ".equ var, 123    li.w/d resgister, var".
    
    gas/
            * config/loongarch-parse.y
            * config/tc-loongarch.c
    
            Add four testcases.One is a program using constant variable,
            one test using label is unsupported, and another two test
            almost instructions that can load immediate.
    
    gas/
            * testsuite/gas/loongarch/li.d
            * testsuite/gas/loongarch/li.s
            * testsuite/gas/loongarch/imm_ins_label-fail.d
            * testsuite/gas/loongarch/imm_ins_label-fail.l
            * testsuite/gas/loongarch/imm_ins_label-fail.s
            * testsuite/gas/loongarch/imm_ins.d
            * testsuite/gas/loongarch/imm_ins.s
            * testsuite/gas/loongarch/imm_ins_32.d
            * testsuite/gas/loongarch/imm_ins_32.s

Diff:
---
 gas/config/loongarch-parse.y                     | 20 ++++++
 gas/config/tc-loongarch.c                        | 18 -----
 gas/testsuite/gas/loongarch/imm_ins.d            | 80 +++++++++++++++++++++++
 gas/testsuite/gas/loongarch/imm_ins.s            | 83 ++++++++++++++++++++++++
 gas/testsuite/gas/loongarch/imm_ins_32.d         | 57 ++++++++++++++++
 gas/testsuite/gas/loongarch/imm_ins_32.s         | 60 +++++++++++++++++
 gas/testsuite/gas/loongarch/imm_ins_label-fail.d |  3 +
 gas/testsuite/gas/loongarch/imm_ins_label-fail.l |  3 +
 gas/testsuite/gas/loongarch/imm_ins_label-fail.s |  3 +
 gas/testsuite/gas/loongarch/li.d                 | 21 ++++++
 gas/testsuite/gas/loongarch/li.s                 | 22 +++++++
 11 files changed, 352 insertions(+), 18 deletions(-)

diff --git a/gas/config/loongarch-parse.y b/gas/config/loongarch-parse.y
index 902d7204e8e..8704687706d 100644
--- a/gas/config/loongarch-parse.y
+++ b/gas/config/loongarch-parse.y
@@ -100,6 +100,25 @@ my_getExpression (expressionS *ep, const char *str)
   return ret;
 }
 
+static void
+emit_const_var (const char *op)
+{
+  expressionS ep;
+
+  if (end <= top)
+    as_fatal (_("expr too huge"));
+
+  my_getExpression (&ep, op);
+
+  if (ep.X_op != O_constant)
+    as_bad ("illegal operand: %s", op);
+
+  top->value.X_op = O_constant;
+  top->value.X_add_number = ep.X_add_number;
+  top->type = BFD_RELOC_LARCH_SOP_PUSH_ABSOLUTE;
+  top++;
+}
+
 static void
 reloc (const char *op_c_str, const char *id_c_str, offsetT addend)
 {
@@ -318,6 +337,7 @@ offsetT imm;
 
 primary_expression
 	: INTEGER {emit_const ($1);}
+	| IDENTIFIER {emit_const_var ($1);}
 	| '(' expression ')'
 	| '%' IDENTIFIER '(' IDENTIFIER addend ')' {reloc ($2, $4, $5); free ($2); free ($4);}
 	| '%' IDENTIFIER '(' INTEGER addend ')' {reloc ($2, NULL, $4 + $5); free ($2);}
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index fbbaca55085..963428e95d9 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -582,24 +582,6 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2,
       if (!ip->match_now)
 	break;
 
-      if (esc_ch1 == 's')
-	switch (esc_ch2)
-	  {
-	  case 'c':
-	    ip->match_now = reloc_num == 0;
-	    break;
-	  }
-      else
-	switch (esc_ch2)
-	  {
-	  case 'c':
-	    ip->match_now = reloc_num == 0 && 0 <= imm;
-	    break;
-	  }
-
-      if (!ip->match_now)
-	break;
-
       ret = imm;
       if (reloc_num)
 	{
diff --git a/gas/testsuite/gas/loongarch/imm_ins.d b/gas/testsuite/gas/loongarch/imm_ins.d
new file mode 100644
index 00000000000..0ceaead3edf
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/imm_ins.d
@@ -0,0 +1,80 @@
+#as:
+#objdump: -dr
+#skip: loongarch32-*-*
+
+.*:[    ]+file format .*
+
+
+Disassembly of section .text:
+
+00000000.* <.text>:
+[ 	]+0:[ 	]+03848c0c[ 	]+ori[ 	]+\$t0,[ 	]+\$zero,[ 	]+0x123
+[ 	]+4:[ 	]+15ffe00d[ 	]+lu12i.w[ 	]+\$t1,[ 	]+-256\(0xfff00\)
+[ 	]+8:[ 	]+16001fed[ 	]+lu32i.d[ 	]+\$t1,[ 	]+255\(0xff\)
+[ 	]+c:[ 	]+02bffc0e[ 	]+addi.w[ 	]+\$t2,[ 	]+\$zero,[ 	]+-1\(0xfff\)
+[ 	]+10:[ 	]+1601ffee[ 	]+lu32i.d[ 	]+\$t2,[ 	]+4095\(0xfff\)
+[ 	]+14:[ 	]+0004b58b[ 	]+alsl.w[ 	]+\$a7,[ 	]+\$t0,[ 	]+\$t1,[ 	]+0x2
+[ 	]+18:[ 	]+0006b58b[ 	]+alsl.wu[ 	]+\$a7,[ 	]+\$t0,[ 	]+\$t1,[ 	]+0x2
+[ 	]+1c:[ 	]+0009358b[ 	]+bytepick.w[ 	]+\$a7,[ 	]+\$t0,[ 	]+\$t1,[ 	]+0x2
+[ 	]+20:[ 	]+000d358b[ 	]+bytepick.d[ 	]+\$a7,[ 	]+\$t0,[ 	]+\$t1,[ 	]+0x2
+[ 	]+24:[ 	]+002a0002[ 	]+break[ 	]+0x2
+[ 	]+28:[ 	]+002a8002[ 	]+dbcl[ 	]+0x2
+[ 	]+2c:[ 	]+002b0002[ 	]+syscall[ 	]+0x2
+[ 	]+30:[ 	]+002cb58b[ 	]+alsl.d[ 	]+\$a7,[ 	]+\$t0,[ 	]+\$t1,[ 	]+0x2
+[ 	]+34:[ 	]+0040898b[ 	]+slli.w[ 	]+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 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+f8:[ 	]+2a4401ac[ 	]+ld.hu[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+fc:[ 	]+2a8401ac[ 	]+ld.wu[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+100:[ 	]+2ac401a2[ 	]+preld[ 	]+0x2,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+104:[ 	]+382c39a2[ 	]+preldx[ 	]+0x2,[ 	]+\$t1,[ 	]+\$t2
+[ 	]+108:[ 	]+2b048d8a[ 	]+fld.s[ 	]+\$ft2,[ 	]+\$t0,[ 	]+291\(0x123\)
+[ 	]+10c:[ 	]+2b448d8a[ 	]+fst.s[ 	]+\$ft2,[ 	]+\$t0,[ 	]+291\(0x123\)
+[ 	]+110:[ 	]+2b848d8a[ 	]+fld.d[ 	]+\$ft2,[ 	]+\$t0,[ 	]+291\(0x123\)
+[ 	]+114:[ 	]+2bc48d8a[ 	]+fst.d[ 	]+\$ft2,[ 	]+\$t0,[ 	]+291\(0x123\)
diff --git a/gas/testsuite/gas/loongarch/imm_ins.s b/gas/testsuite/gas/loongarch/imm_ins.s
new file mode 100644
index 00000000000..f6a4e7455f8
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/imm_ins.s
@@ -0,0 +1,83 @@
+.equ a, 0x123
+.equ b, 0xfffff00000
+.equ c, 0xfffffffffff
+.equ d, 2
+.equ e,0x100
+
+li.w $r12, a
+li.d $r13, b
+li.d $r14, c
+
+alsl.w $r11,$r12,$r13,d
+alsl.wu $r11,$r12,$r13,d
+bytepick.w $r11,$r12,$r13,d
+bytepick.d $r11,$r12,$r13,d
+
+break d
+dbcl d
+syscall d
+
+alsl.d $r11,$r12, $r13,d
+slli.w $r11,$r12,d
+slli.d $r11,$r12,d
+srli.w $r11,$r12,d
+srli.d $r12,$r13,d
+srai.w $r12,$r13,d
+srai.d $r12,$r13,d
+
+bstrins.w $r12,$r13,d,d
+bstrins.d $r12,$r13,d,d
+bstrpick.d $r12,$r13,d,d
+bstrpick.d $r12,$r13,d,d
+
+slti $r12,$r13,a
+sltui $r12,$r13,a
+addi.w $r12,$r13,a
+addi.d $r12,$r13,a
+lu52i.d $r12,$r13,a
+andi $r12,$r13,d
+ori  $r12,$r13,d
+xori $r12,$r13,d
+addu16i.d $r12,$r13,d
+lu12i.w $r12,a
+lu32i.d $r12,a
+pcaddi $r12,a
+pcalau12i $r12,a
+pcaddu12i $r12,a
+pcaddu18i $r12,a
+
+csrrd $r12,a
+csrwr $r12,a
+csrxchg $r12,$r13,d
+cacop d,$r13,d
+lddir $r12,$r13,d
+ldpte $r12,d
+
+invtlb d,$r13,$r14
+
+ll.w $r12,$r13,e
+sc.w $r12,$r13,e
+ll.d $r12,$r13,e
+sc.d $r12,$r13,e
+ldptr.w $r12,$r13,e
+stptr.w $r12,$r13,e
+ldptr.d $r12,$r13,e
+stptr.d $r12,$r13,e
+ld.b $r12,$r13,e
+ld.h $r12,$r13,e
+ld.w $r12,$r13,e
+ld.d $r12,$r13,e
+st.b $r12,$r13,e
+st.h $r12,$r13,e
+st.w $r12,$r13,e
+st.d $r12,$r13,e
+ld.bu $r12,$r13,e
+ld.hu $r12,$r13,e
+ld.wu $r12,$r13,e
+preld d,$r13,e
+preldx d,$r13,$r14
+
+fld.s $f10,$r12,a
+fst.s $f10,$r12,a
+fld.d $f10,$r12,a
+fst.d $f10,$r12,a
diff --git a/gas/testsuite/gas/loongarch/imm_ins_32.d b/gas/testsuite/gas/loongarch/imm_ins_32.d
new file mode 100644
index 00000000000..0a826bfba5b
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/imm_ins_32.d
@@ -0,0 +1,57 @@
+#as:
+#objdump: -dr
+#skip: loongarch64-*-*
+
+.*:[    ]+file format .*
+
+
+Disassembly of section .text:
+
+00000000.* <.text>:
+[ 	]+0:[ 	]+03848c0c[ 	]+ori[ 	]+\$t0,[ 	]+\$z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 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+8c:[ 	]+284401ac[ 	]+ld.h[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+90:[ 	]+288401ac[ 	]+ld.w[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+94:[ 	]+290401ac[ 	]+st.b[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+98:[ 	]+294401ac[ 	]+st.h[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+9c:[ 	]+298401ac[ 	]+st.w[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+a0:[ 	]+2a0401ac[ 	]+ld.bu[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+a4:[ 	]+2a4401ac[ 	]+ld.hu[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+a8:[ 	]+2a8401ac[ 	]+ld.wu[ 	]+\$t0,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+ac:[ 	]+2ac401a2[ 	]+preld[ 	]+0x2,[ 	]+\$t1,[ 	]+256\(0x100\)
+[ 	]+b0:[ 	]+382c39a2[ 	]+preldx[ 	]+0x2,[ 	]+\$t1,[ 	]+\$t2
+[ 	]+b4:[ 	]+2b048d8a[ 	]+fld.s[ 	]+\$ft2,[ 	]+\$t0,[ 	]+291\(0x123\)
+[ 	]+b8:[ 	]+2b448d8a[ 	]+fst.s[ 	]+\$ft2,[ 	]+\$t0,[ 	]+291\(0x123\)
diff --git a/gas/testsuite/gas/loongarch/imm_ins_32.s b/gas/testsuite/gas/loongarch/imm_ins_32.s
new file mode 100644
index 00000000000..e105548e702
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/imm_ins_32.s
@@ -0,0 +1,60 @@
+.equ a, 0x123
+.equ d, 2
+.equ e,0x100
+
+li.w $r12, a
+
+alsl.w $r11,$r12,$r13,d
+alsl.wu $r11,$r12,$r13,d
+bytepick.w $r11,$r12,$r13,d
+
+break d
+dbcl d
+syscall d
+
+slli.w $r11,$r12,d
+srli.w $r11,$r12,d
+srai.w $r12,$r13,d
+
+bstrins.w $r12,$r13,d,d
+
+slti $r12,$r13,a
+sltui $r12,$r13,a
+addi.w $r12,$r13,a
+andi $r12,$r13,d
+ori  $r12,$r13,d
+xori $r12,$r13,d
+lu12i.w $r12,a
+pcaddi $r12,a
+pcalau12i $r12,a
+pcaddu12i $r12,a
+pcaddu18i $r12,a
+
+csrrd $r12,a
+csrwr $r12,a
+csrxchg $r12,$r13,d
+cacop d,$r13,d
+lddir $r12,$r13,d
+ldpte $r12,d
+
+invtlb d,$r13,$r14
+
+ll.w $r12,$r13,e
+sc.w $r12,$r13,e
+ll.d $r12,$r13,e
+sc.d $r12,$r13,e
+ldptr.w $r12,$r13,e
+stptr.w $r12,$r13,e
+ld.h $r12,$r13,e
+ld.w $r12,$r13,e
+st.b $r12,$r13,e
+st.h $r12,$r13,e
+st.w $r12,$r13,e
+ld.bu $r12,$r13,e
+ld.hu $r12,$r13,e
+ld.wu $r12,$r13,e
+preld d,$r13,e
+preldx d,$r13,$r14
+
+fld.s $f10,$r12,a
+fst.s $f10,$r12,a
diff --git a/gas/testsuite/gas/loongarch/imm_ins_label-fail.d b/gas/testsuite/gas/loongarch/imm_ins_label-fail.d
new file mode 100644
index 00000000000..4301a0073c0
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/imm_ins_label-fail.d
@@ -0,0 +1,3 @@
+#as:
+#source: imm_ins_label-fail.s
+#error_output: imm_ins_label-fail.l
diff --git a/gas/testsuite/gas/loongarch/imm_ins_label-fail.l b/gas/testsuite/gas/loongarch/imm_ins_label-fail.l
new file mode 100644
index 00000000000..e0fec2fed19
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/imm_ins_label-fail.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*Error: illegal operand: Label
+.*Error: illegal operand: Label
diff --git a/gas/testsuite/gas/loongarch/imm_ins_label-fail.s b/gas/testsuite/gas/loongarch/imm_ins_label-fail.s
new file mode 100644
index 00000000000..84b2d192bb5
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/imm_ins_label-fail.s
@@ -0,0 +1,3 @@
+Label:
+    li.w $r12, Label
+    addi.w $r12, $r13, Label
diff --git a/gas/testsuite/gas/loongarch/li.d b/gas/testsuite/gas/loongarch/li.d
new file mode 100644
index 00000000000..850a3f48e30
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/li.d
@@ -0,0 +1,21 @@
+#as:
+#objdump: -dr
+#skip: loongarch32-*-*
+
+.*:[    ]+file format .*
+
+
+Disassembly of section .text:
+
+00000000.* <_start>:
+[ 	]+0:[ 	]+03803c06[ 	]+ori[ 	]+\$a2,[ 	]+\$zero,[ 	]+0xf
+[ 	]+4:[ 	]+1a000005[ 	]+pcalau12i[ 	]+\$a1,[ 	]+0
+[ 	]+4:[ 	]+R_LARCH_PCALA_HI20[ 	]+.rodata
+[ 	]+8:[ 	]+02c000a5[ 	]+addi.d[ 	]+\$a1,[ 	]+\$a1,[ 	]+0
+[ 	]+8:[ 	]+R_LARCH_PCALA_LO12[ 	]+.rodata
+[ 	]+c:[ 	]+03800404[ 	]+ori[ 	]+\$a0,[ 	]+\$zero,[ 	]+0x1
+[ 	]+10:[ 	]+0381000b[ 	]+ori[ 	]+\$a7,[ 	]+\$zero,[ 	]+0x40
+[ 	]+14:[ 	]+002b0000[ 	]+syscall[ 	]+0x0
+[ 	]+18:[ 	]+00150004[ 	]+move[ 	]+\$a0,[ 	]+\$zero
+[ 	]+1c:[ 	]+0381740b[ 	]+ori[ 	]+\$a7,[ 	]+\$zero,[ 	]+0x5d
+[ 	]+20:[ 	]+002b0000[ 	]+syscall[ 	]+0x0
diff --git a/gas/testsuite/gas/loongarch/li.s b/gas/testsuite/gas/loongarch/li.s
new file mode 100644
index 00000000000..e95a527fc10
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/li.s
@@ -0,0 +1,22 @@
+.equ EXIT_SUCCESS, 0
+.equ STDOUT, 1
+.equ SYS_exit, 93
+.equ SYS_write, 64
+
+.section .rodata
+msg:
+    .string "hello, world!\n"
+    len = . - msg
+
+.text
+    .globl  _start
+_start:
+    li.w        $a2, len
+    la.local    $a1, msg
+    li.w        $a0, STDOUT
+    li.w        $a7, SYS_write
+    syscall     0x0
+
+    li.w        $a0, EXIT_SUCCESS
+    li.w        $a7, SYS_exit
+    syscall     0x0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-22  2:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-22  2:25 [binutils-gdb] LoongArch: gas: add support using constant variable in instructions liu & zhensong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).