aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorFeiyang Chen <chenfeiyang@loongson.cn>2023-06-16 11:16:10 +0800
committerliuzhensong <liuzhensong@loongson.cn>2023-06-25 15:06:32 +0800
commit4142b2368353bda6d2e5ff80640c012b80f84024 (patch)
tree008063c1b9de2d1e466f13b7b603dbf298a551c5 /gas
parent0e389a1595b792a70aa76e60dc3e5244a10f2a55 (diff)
downloadfsf-binutils-gdb-4142b2368353bda6d2e5ff80640c012b80f84024.zip
fsf-binutils-gdb-4142b2368353bda6d2e5ff80640c012b80f84024.tar.gz
fsf-binutils-gdb-4142b2368353bda6d2e5ff80640c012b80f84024.tar.bz2
LoongArch: Support referring to FCSRs as $fcsrX
Previously, FCSRs were referred to as $rX, which seemed strange. We refer to FCSRs as $fcsrX, which ensures compatibility with LLVM IAS as well. gas/ChangeLog: * config/tc-loongarch.c: (loongarch_fc_normal_name): New definition. (loongarch_fc_numeric_name): New definition. (loongarch_single_float_opcodes): Modify `movgr2fcsr` and `movfcsr2gr`. testsuite/gas/loongarch/float_op.d: Likewise. testsuite/gas/loongarch/float_op.s: Likewise. include/ChangeLog: * opcode/loongarch.h: (loongarch_fc_normal_name): New extern. (loongarch_fc_numeric_name): New extern. opcodes/ChangeLog: * opcodes/loongarch-dis.c (loongarch_after_parse_args): Support referring to FCSRs as $fcsrX. * opcodes/loongarch-opc.c (loongarch_args_parser_can_match_arg_helper): Likewise. Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
Diffstat (limited to 'gas')
-rw-r--r--gas/config/tc-loongarch.c29
-rw-r--r--gas/testsuite/gas/loongarch/float_op.d4
-rw-r--r--gas/testsuite/gas/loongarch/float_op.s4
3 files changed, 32 insertions, 5 deletions
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index d1c5ce2..ba5b626 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -223,6 +223,8 @@ md_parse_option (int c, const char *arg)
static struct htab *r_htab = NULL;
static struct htab *f_htab = NULL;
+static struct htab *fc_htab = NULL;
+static struct htab *fcn_htab = NULL;
static struct htab *c_htab = NULL;
static struct htab *cr_htab = NULL;
static struct htab *v_htab = NULL;
@@ -286,6 +288,20 @@ loongarch_after_parse_args ()
str_hash_insert (f_htab, loongarch_f_normal_name[i], (void *) (i + 1),
0);
+ if (!fc_htab)
+ fc_htab = str_htab_create (), str_hash_insert (fc_htab, "", 0, 0);
+
+ for (i = 0; i < ARRAY_SIZE (loongarch_fc_normal_name); i++)
+ str_hash_insert (fc_htab, loongarch_fc_normal_name[i], (void *) (i + 1),
+ 0);
+
+ if (!fcn_htab)
+ fcn_htab = str_htab_create (), str_hash_insert (fcn_htab, "", 0, 0);
+
+ for (i = 0; i < ARRAY_SIZE (loongarch_fc_numeric_name); i++)
+ str_hash_insert (fcn_htab, loongarch_fc_numeric_name[i], (void *) (i + 1),
+ 0);
+
if (!c_htab)
c_htab = str_htab_create (), str_hash_insert (c_htab, "", 0, 0);
@@ -666,7 +682,18 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2,
ret = imm - 1;
break;
case 'f':
- imm = (intptr_t) str_hash_find (f_htab, arg);
+ switch (esc_ch2)
+ {
+ case 'c':
+ imm = (intptr_t) str_hash_find (fc_htab, arg);
+ if (0 >= imm)
+ {
+ imm = (intptr_t) str_hash_find (fcn_htab, arg);
+ }
+ break;
+ default:
+ imm = (intptr_t) str_hash_find (f_htab, arg);
+ }
ip->match_now = 0 < imm;
ret = imm - 1;
break;
diff --git a/gas/testsuite/gas/loongarch/float_op.d b/gas/testsuite/gas/loongarch/float_op.d
index cdc41d4..f9d3b89 100644
--- a/gas/testsuite/gas/loongarch/float_op.d
+++ b/gas/testsuite/gas/loongarch/float_op.d
@@ -49,8 +49,8 @@ Disassembly of section .text:
[ ]+9c:[ ]+0114b424 [ ]+movfr2gr.s[ ]+[ ]+\$a0, \$fa1
[ ]+a0:[ ]+0114b824 [ ]+movfr2gr.d[ ]+[ ]+\$a0, \$fa1
[ ]+a4:[ ]+0114bc24 [ ]+movfrh2gr.s [ ]+\$a0, \$fa1
-[ ]+a8:[ ]+0114c0a4 [ ]+movgr2fcsr[ ]+[ ]+\$a0, \$a1
-[ ]+ac:[ ]+0114c8a4 [ ]+movfcsr2gr[ ]+[ ]+\$a0, \$a1
+[ ]+a8:[ ]+0114c0a0 [ ]+movgr2fcsr[ ]+[ ]+\$fcsr0, \$a1
+[ ]+ac:[ ]+0114c804 [ ]+movfcsr2gr[ ]+[ ]+\$a0, \$fcsr0
[ ]+b0:[ ]+0114d020 [ ]+movfr2cf[ ]+[ ]+\$fcc0, \$fa1
[ ]+b4:[ ]+0114d4a0 [ ]+movcf2fr[ ]+[ ]+\$fa0, \$fcc5
[ ]+b8:[ ]+0114d8a0 [ ]+movgr2cf[ ]+[ ]+\$fcc0, \$a1
diff --git a/gas/testsuite/gas/loongarch/float_op.s b/gas/testsuite/gas/loongarch/float_op.s
index da1a198..2e3ec5b 100644
--- a/gas/testsuite/gas/loongarch/float_op.s
+++ b/gas/testsuite/gas/loongarch/float_op.s
@@ -40,8 +40,8 @@ movgr2frh.w $f0,$r5
movfr2gr.s $r4,$f1
movfr2gr.d $r4,$f1
movfrh2gr.s $r4,$f1
-movgr2fcsr $r4,$r5
-movfcsr2gr $r4,$r5
+movgr2fcsr $fcsr0,$r5
+movfcsr2gr $r4,$fcsr0
movfr2cf $fcc0,$f1
movcf2fr $f0,$fcc5
movgr2cf $fcc0,$r5