aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog9
-rwxr-xr-xgas/config/bfin-aux.h3
-rw-r--r--gas/config/bfin-parse.y21
-rw-r--r--gas/config/tc-bfin.c142
-rw-r--r--gas/config/tc-bfin.h2
-rw-r--r--gas/testsuite/ChangeLog7
-rw-r--r--gas/testsuite/gas/bfin/bfin.exp3
-rw-r--r--gas/testsuite/gas/bfin/loop.d7
-rw-r--r--gas/testsuite/gas/bfin/loop.s5
-rw-r--r--gas/testsuite/gas/bfin/loop2.d7
-rw-r--r--gas/testsuite/gas/bfin/loop2.s5
-rw-r--r--gas/testsuite/gas/bfin/loop3.d7
-rw-r--r--gas/testsuite/gas/bfin/loop3.s5
13 files changed, 104 insertions, 119 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index b5460ae..30d4c62 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,12 @@
+2009-09-03 Jie Zhang <jie.zhang@analog.com>
+
+ * config/bfin-parse.y (asm_1): Add LOOP_BEGIN and LOOP_END.
+ * config/tc-bfin.c (bfin_start_line_hook): Remove.
+ (bfin_loop_beginend): New.
+ * config/tc-bfin.h (bfin_start_line_hook): Don't declare.
+ (md_start_line_hook): Don't define.
+ * config/bfin-aux.h (bfin_loop_beginend): Declare.
+
2009-09-03 Tristan Gingold <gingold@adacore.com>
* config/tc-ia64.c (ia64_vms_note): Use lbasename instead of basename.
diff --git a/gas/config/bfin-aux.h b/gas/config/bfin-aux.h
index d470797..9c71939 100755
--- a/gas/config/bfin-aux.h
+++ b/gas/config/bfin-aux.h
@@ -126,6 +126,9 @@ bfin_gen_loopsetup (Expr_Node *soffset, REG_T c, int rop,
INSTR_T
bfin_gen_loop (Expr_Node *expr, REG_T reg, int rop, REG_T preg);
+void
+bfin_loop_beginend (Expr_Node *expr, int begin);
+
INSTR_T
bfin_gen_pushpopmultiple (int dr, int pr, int d, int p, int w);
diff --git a/gas/config/bfin-parse.y b/gas/config/bfin-parse.y
index 72db6d9..719edaf 100644
--- a/gas/config/bfin-parse.y
+++ b/gas/config/bfin-parse.y
@@ -3525,6 +3525,27 @@ asm_1:
else
return yyerror ("Bad register or values for LOOP");
}
+
+/* LOOP_BEGIN. */
+ | LOOP_BEGIN expr
+ {
+ if (!IS_RELOC ($2))
+ return yyerror ("Invalid expression in LOOP_BEGIN statement");
+
+ bfin_loop_beginend ($2, 1);
+ $$ = 0;
+ }
+
+/* LOOP_END. */
+ | LOOP_END expr
+ {
+ if (!IS_RELOC ($2))
+ return yyerror ("Invalid expression in LOOP_END statement");
+
+ bfin_loop_beginend ($2, 0);
+ $$ = 0;
+ }
+
/* pseudoDEBUG. */
| DBG
diff --git a/gas/config/tc-bfin.c b/gas/config/tc-bfin.c
index 58b7ed1..958f63d 100644
--- a/gas/config/tc-bfin.c
+++ b/gas/config/tc-bfin.c
@@ -1016,123 +1016,6 @@ bfin_fix_adjustable (fixS *fixP)
}
}
-
-/* Handle the LOOP_BEGIN and LOOP_END statements.
- Parse the Loop_Begin/Loop_End and create a label. */
-void
-bfin_start_line_hook ()
-{
- bfd_boolean maybe_begin = FALSE;
- bfd_boolean maybe_end = FALSE;
-
- char *c1, *label_name;
- symbolS *line_label;
- char *c = input_line_pointer;
- int cr_num = 0;
-
- while (ISSPACE (*c))
- {
- if (*c == '\n')
- cr_num++;
- c++;
- }
-
- /* Look for Loop_Begin or Loop_End statements. */
-
- if (*c != 'L' && *c != 'l')
- return;
-
- c++;
- if (*c != 'O' && *c != 'o')
- return;
-
- c++;
- if (*c != 'O' && *c != 'o')
- return;
-
- c++;
- if (*c != 'P' && *c != 'p')
- return;
-
- c++;
- if (*c != '_')
- return;
-
- c++;
- if (*c == 'E' || *c == 'e')
- maybe_end = TRUE;
- else if (*c == 'B' || *c == 'b')
- maybe_begin = TRUE;
- else
- return;
-
- if (maybe_end)
- {
- c++;
- if (*c != 'N' && *c != 'n')
- return;
-
- c++;
- if (*c != 'D' && *c != 'd')
- return;
- }
-
- if (maybe_begin)
- {
- c++;
- if (*c != 'E' && *c != 'e')
- return;
-
- c++;
- if (*c != 'G' && *c != 'g')
- return;
-
- c++;
- if (*c != 'I' && *c != 'i')
- return;
-
- c++;
- if (*c != 'N' && *c != 'n')
- return;
- }
-
- c++;
- while (ISSPACE (*c)) c++;
- c1 = c;
- while (ISALPHA (*c) || ISDIGIT (*c) || *c == '_') c++;
-
- if (input_line_pointer[-1] == '\n')
- bump_line_counters ();
-
- while (cr_num--)
- bump_line_counters ();
-
- input_line_pointer = c;
- if (maybe_end)
- {
- label_name = (char *) xmalloc ((c - c1) + strlen ("__END") + 5);
- label_name[0] = 0;
- strcat (label_name, "L$L$");
- strncat (label_name, c1, c-c1);
- strcat (label_name, "__END");
- }
- else /* maybe_begin. */
- {
- label_name = (char *) xmalloc ((c - c1) + strlen ("__BEGIN") + 5);
- label_name[0] = 0;
- strcat (label_name, "L$L$");
- strncat (label_name, c1, c-c1);
- strcat (label_name, "__BEGIN");
- }
-
- line_label = colon (label_name);
-
- /* Loop_End follows the last instruction in the loop.
- Adjust label address. */
- if (maybe_end)
- ((struct local_symbol *) line_label)->lsy_value -= last_insn_size;
-}
-
/* Special extra functions that help bfin-parse.y perform its job. */
struct obstack mempool;
@@ -2145,6 +2028,31 @@ bfin_gen_loop (Expr_Node *expr, REG_T reg, int rop, REG_T preg)
return bfin_gen_loopsetup(lbegin, reg, rop, lend, preg);
}
+void
+bfin_loop_beginend (Expr_Node *expr, int begin)
+{
+ const char *loopsym;
+ char *label_name;
+ symbolS *line_label;
+ const char *suffix = begin ? "__BEGIN" : "__END";
+
+ loopsym = expr->value.s_value;
+ label_name = (char *) xmalloc (strlen (loopsym) + strlen (suffix) + 5);
+
+ label_name[0] = 0;
+
+ strcat (label_name, "L$L$");
+ strcat (label_name, loopsym);
+ strcat (label_name, suffix);
+
+ line_label = colon (label_name);
+
+ /* LOOP_END follows the last instruction in the loop.
+ Adjust label address. */
+ if (!begin)
+ ((struct local_symbol *) line_label)->lsy_value -= last_insn_size;
+}
+
bfd_boolean
bfin_eol_in_insn (char *line)
{
diff --git a/gas/config/tc-bfin.h b/gas/config/tc-bfin.h
index f949b4e..c5819fc 100644
--- a/gas/config/tc-bfin.h
+++ b/gas/config/tc-bfin.h
@@ -39,10 +39,8 @@
#define WORKING_DOT_WORD
-extern void bfin_start_line_hook (void);
extern bfd_boolean bfin_start_label (char *, char *);
-#define md_start_line_hook() bfin_start_line_hook()
#define md_number_to_chars number_to_chars_littleendian
#define md_convert_frag(b,s,f) as_fatal ("bfin convert_frag\n");
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index d639cee..f75cb12 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-03 Jie Zhang <jie.zhang@analog.com>
+
+ * gas/bfin/loop.s, gas/bfin/loop.d: New test.
+ * gas/bfin/loop2.s, gas/bfin/loop2.d: New test.
+ * gas/bfin/loop3.s, gas/bfin/loop3.d: New test.
+ * gas/bfin/bfin.exp: Add the new tests.
+
2009-09-02 Jie Zhang <jie.zhang@analog.com>
From Bernd Schmidt <bernd.schmidt@analog.com>
diff --git a/gas/testsuite/gas/bfin/bfin.exp b/gas/testsuite/gas/bfin/bfin.exp
index 58d33b5..59eed65 100644
--- a/gas/testsuite/gas/bfin/bfin.exp
+++ b/gas/testsuite/gas/bfin/bfin.exp
@@ -20,6 +20,9 @@ if [istarget bfin*-*-*] {
run_dump_test "load"
run_dump_test "logical"
run_dump_test "logical2"
+ run_dump_test "loop"
+ run_dump_test "loop2"
+ run_dump_test "loop3"
run_dump_test "misc"
run_dump_test "move"
run_dump_test "move2"
diff --git a/gas/testsuite/gas/bfin/loop.d b/gas/testsuite/gas/bfin/loop.d
new file mode 100644
index 0000000..2ecd459
--- /dev/null
+++ b/gas/testsuite/gas/bfin/loop.d
@@ -0,0 +1,7 @@
+#readelf: --relocs
+#name: loop
+
+Relocation section '\.rela\.text' .*:
+.*
+.* R_BFIN_GOT17M4 0+00 _foo \+ 0
+.* R_BFIN_PCREL24 0+00 _bar \+ 0
diff --git a/gas/testsuite/gas/bfin/loop.s b/gas/testsuite/gas/bfin/loop.s
new file mode 100644
index 0000000..43a7ed2
--- /dev/null
+++ b/gas/testsuite/gas/bfin/loop.s
@@ -0,0 +1,5 @@
+ LOOP bug LC0 = P0>>1;
+ LOOP_BEGIN bug;
+ R0 = [P3+_foo@GOT17M4];
+ LOOP_END bug;
+ call _bar;
diff --git a/gas/testsuite/gas/bfin/loop2.d b/gas/testsuite/gas/bfin/loop2.d
new file mode 100644
index 0000000..79c167b
--- /dev/null
+++ b/gas/testsuite/gas/bfin/loop2.d
@@ -0,0 +1,7 @@
+#readelf: --relocs
+#name: loop2
+
+Relocation section '\.rela\.text' .*:
+.*
+.* R_BFIN_GOT17M4 0+00 _foo \+ 0
+.* R_BFIN_PCREL24 0+00 _bar \+ 0
diff --git a/gas/testsuite/gas/bfin/loop2.s b/gas/testsuite/gas/bfin/loop2.s
new file mode 100644
index 0000000..e8c7600
--- /dev/null
+++ b/gas/testsuite/gas/bfin/loop2.s
@@ -0,0 +1,5 @@
+ LOOP .bug LC0 = P0>>1;
+ LOOP_BEGIN .bug;
+ R0 = [P3+_foo@GOT17M4];
+ LOOP_END .bug;
+ call _bar;
diff --git a/gas/testsuite/gas/bfin/loop3.d b/gas/testsuite/gas/bfin/loop3.d
new file mode 100644
index 0000000..0097d78
--- /dev/null
+++ b/gas/testsuite/gas/bfin/loop3.d
@@ -0,0 +1,7 @@
+#readelf: --relocs
+#name: loop3
+
+Relocation section '\.rela\.text' .*:
+.*
+.* R_BFIN_GOT17M4 0+00 _foo \+ 0
+.* R_BFIN_PCREL24 0+00 _bar \+ 0
diff --git a/gas/testsuite/gas/bfin/loop3.s b/gas/testsuite/gas/bfin/loop3.s
new file mode 100644
index 0000000..ef1a882
--- /dev/null
+++ b/gas/testsuite/gas/bfin/loop3.s
@@ -0,0 +1,5 @@
+ LOOP $bug LC0 = P0>>1;
+ LOOP_BEGIN $bug;
+ R0 = [P3+_foo@GOT17M4];
+ LOOP_END $bug;
+ call _bar;