* [PATCH] new pseudo-ops .ifb/.ifnb
@ 2005-04-28 8:18 Jan Beulich
2005-04-28 15:17 ` Ian Lance Taylor
2005-05-05 9:58 ` Nick Clifton
0 siblings, 2 replies; 4+ messages in thread
From: Jan Beulich @ 2005-04-28 8:18 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 5665 bytes --]
In preparation of adding support for macros with variable number of
arguments, this adds new conditional pseudo-op .ifb and .ifnb, which
check whether their arguments are (non-)blank / (non-)empty.
Built and tested natively on i686-pc-linux-gnu and as cross tools for a
large number of targets (hosted on x86_64-unknown-linux-gnu).
Jan
gas/
2005-04-27 Jan Beulich <jbeulich@novell.com>
* cond.c (s_ifb): New.
* read.c (potable): Add s_ifb as handler for .ifb and .ifnb.
* read.h (s_ifb): Prototype.
* doc/as.texinfo: Document .ifb and .ifnb.
gas/testsuite/
2005-04-27 Jan Beulich <jbeulich@novell.com>
* gas/all/cond.s: Also test .ifb/.ifnb.
* gas/all/cond.d: Adjust.
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/cond.c 2005-03-04 15:51:39.000000000 +0100
+++ 2005-04-26/gas/cond.c 2005-04-27 11:37:16.000000000 +0200
@@ -181,6 +181,40 @@ s_if (int arg)
demand_empty_rest_of_line ();
}
+/* Performs the .ifb (test_blank == 1) and
+ the .ifnb (test_blank == 0) pseudo op. */
+
+void
+s_ifb (int test_blank)
+{
+ struct conditional_frame cframe;
+
+ initialize_cframe (&cframe);
+
+ if (cframe.dead_tree)
+ cframe.ignoring = 1;
+ else
+ {
+ int is_eol;
+
+ SKIP_WHITESPACE ();
+ is_eol = is_end_of_line[(unsigned char) *input_line_pointer];
+ cframe.ignoring = (test_blank == !is_eol);
+ }
+
+ current_cframe = ((struct conditional_frame *)
+ obstack_copy (&cond_obstack, &cframe,
+ sizeof (cframe)));
+
+ if (LISTING_SKIP_COND ()
+ && cframe.ignoring
+ && (cframe.previous_cframe == NULL
+ || ! cframe.previous_cframe->ignoring))
+ listing_list (2);
+
+ ignore_rest_of_line ();
+}
+
/* Get a string for the MRI IFC or IFNC pseudo-ops. */
static char *
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/doc/as.texinfo 2005-04-13 15:09:21.000000000 +0200
+++ 2005-04-26/gas/doc/as.texinfo 2005-04-27 11:37:16.000000000 +0200
@@ -4456,6 +4456,10 @@ Assembles the following section of code
has been defined. Note a symbol which has been referenced but not yet defined
is considered to be undefined.
+@cindex @code{ifb} directive
+@item .ifb @var{text}
+Assembles the following section of code if the operand is blank (empty).
+
@cindex @code{ifc} directive
@item .ifc @var{string1},@var{string2}
Assembles the following section of code if the two strings are the same. The
@@ -4490,6 +4494,11 @@ to zero.
@item .iflt @var{absolute expression}
Assembles the following section of code if the argument is less than zero.
+@cindex @code{ifnb} directive
+@item .ifnb @var{text}
+Like @code{.ifb}, but the sense of the test is reversed: this assembles the
+following section of code if the operand is non-blank (non-empty).
+
@cindex @code{ifnc} directive
@item .ifnc @var{string1},@var{string2}.
Like @code{.ifc}, but the sense of the test is reversed: this assembles the
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/read.c 2005-04-15 11:46:43.000000000 +0200
+++ 2005-04-26/gas/read.c 2005-04-27 11:37:16.000000000 +0200
@@ -342,6 +342,7 @@ static const pseudo_typeS potable[] = {
{"globl", s_globl, 0},
{"hword", cons, 2},
{"if", s_if, (int) O_ne},
+ {"ifb", s_ifb, 1},
{"ifc", s_ifc, 0},
{"ifdef", s_ifdef, 0},
{"ifeq", s_if, (int) O_eq},
@@ -350,6 +351,7 @@ static const pseudo_typeS potable[] = {
{"ifgt", s_if, (int) O_gt},
{"ifle", s_if, (int) O_le},
{"iflt", s_if, (int) O_lt},
+ {"ifnb", s_ifb, 0},
{"ifnc", s_ifc, 1},
{"ifndef", s_ifdef, 1},
{"ifne", s_if, (int) O_ne},
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/read.h 2005-03-04 15:51:40.000000000 +0100
+++ 2005-04-26/gas/read.h 2005-04-27 11:37:16.000000000 +0200
@@ -158,6 +158,7 @@ extern void s_func (int);
extern void do_s_func (int, const char *);
extern void s_globl (int arg);
extern void s_if (int arg);
+extern void s_ifb (int arg);
extern void s_ifc (int arg);
extern void s_ifdef (int arg);
extern void s_ifeqs (int arg);
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/testsuite/gas/all/cond.d 2001-03-31 08:47:54.000000000 +0200
+++ 2005-04-26/gas/testsuite/gas/all/cond.d 2005-04-26 17:33:32.000000000 +0200
@@ -23,8 +23,18 @@
27[ ]+.elseif 1
29[ ]+.else
31[ ]+.endif
- 32 000c 00 ?00 ?00 ?00[ ]+.p2align 5,0
- 32[ ]+00 ?00 ?00 ?00
- 32[ ]+00 ?00 ?00 ?00
- 32[ ]+00 ?00 ?00 ?00
- 32[ ]+00 ?00 ?00 ?00
+[ ]*[1-9][0-9]*[ ]+
+[ ]*[1-9][0-9]*[ ]+\.macro[ ]+m[ ]+x,[ ]*y[ ]*
+#...
+[ ]*[1-9][0-9]*[ ]+\.endm[ ]*
+[ ]*[1-9][0-9]*[ ]+[0-9a-f]+[048c] FF ?FF ?FF ?FF[ ]+m[ ]+,[ ]*
+[ ]*[1-9][0-9]*[ ]+FF ?FF ?FF ?FF[ ]*
+[ ]*[1-9][0-9]*[ ]+[0-9a-f]+[048c] FF ?FF ?FF ?FF[ ]+m[ ]+,[ ]*10[ ]*
+[ ]*[1-9][0-9]*[ ]+0[0A] ?00 ?00 ?0[0A][ ]*
+[ ]*[1-9][0-9]*[ ]+[0-9a-f]+[048c] 0[0B] ?00 ?00 ?0[0B][ ]+m[ ]+11,[ ]*
+[ ]*[1-9][0-9]*[ ]+FF ?FF ?FF ?FF[ ]*
+[ ]*[1-9][0-9]*[ ]+[0-9a-f]+[048c] 0[0C] ?00 ?00 ?0[0C][ ]+m[ ]+12,[ ]*13[ ]*
+[ ]*[1-9][0-9]*[ ]+0[0D] ?00 ?00 ?0[0D][ ]*
+[ ]*[1-9][0-9]*[ ]+
+[ ]*[1-9][0-9]*[ ]+.*\.p2align 5,0
+#pass
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/testsuite/gas/all/cond.s 2001-03-31 08:47:54.000000000 +0200
+++ 2005-04-26/gas/testsuite/gas/all/cond.s 2005-04-26 17:19:49.000000000 +0200
@@ -29,4 +29,22 @@
.else
.long 9
.endif
+
+ .macro m x, y
+ .ifb \x
+ .long -1
+ .else
+ .long \x
+ .endif
+ .ifnb \y
+ .long \y
+ .else
+ .long -1
+ .endif
+ .endm
+ m ,
+ m , 10
+ m 11,
+ m 12, 13
+
.p2align 5,0
[-- Attachment #2: binutils-mainline-ifb.patch --]
[-- Type: text/plain, Size: 5493 bytes --]
In preparation of adding support for macros with variable number of
arguments, this adds new conditional pseudo-op .ifb and .ifnb, which
check whether their arguments are (non-)blank / (non-)empty.
Built and tested natively on i686-pc-linux-gnu and as cross tools for a
large number of targets (hosted on x86_64-unknown-linux-gnu).
Jan
gas/
2005-04-27 Jan Beulich <jbeulich@novell.com>
* cond.c (s_ifb): New.
* read.c (potable): Add s_ifb as handler for .ifb and .ifnb.
* read.h (s_ifb): Prototype.
* doc/as.texinfo: Document .ifb and .ifnb.
gas/testsuite/
2005-04-27 Jan Beulich <jbeulich@novell.com>
* gas/all/cond.s: Also test .ifb/.ifnb.
* gas/all/cond.d: Adjust.
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/cond.c 2005-03-04 15:51:39.000000000 +0100
+++ 2005-04-26/gas/cond.c 2005-04-27 11:37:16.000000000 +0200
@@ -181,6 +181,40 @@ s_if (int arg)
demand_empty_rest_of_line ();
}
+/* Performs the .ifb (test_blank == 1) and
+ the .ifnb (test_blank == 0) pseudo op. */
+
+void
+s_ifb (int test_blank)
+{
+ struct conditional_frame cframe;
+
+ initialize_cframe (&cframe);
+
+ if (cframe.dead_tree)
+ cframe.ignoring = 1;
+ else
+ {
+ int is_eol;
+
+ SKIP_WHITESPACE ();
+ is_eol = is_end_of_line[(unsigned char) *input_line_pointer];
+ cframe.ignoring = (test_blank == !is_eol);
+ }
+
+ current_cframe = ((struct conditional_frame *)
+ obstack_copy (&cond_obstack, &cframe,
+ sizeof (cframe)));
+
+ if (LISTING_SKIP_COND ()
+ && cframe.ignoring
+ && (cframe.previous_cframe == NULL
+ || ! cframe.previous_cframe->ignoring))
+ listing_list (2);
+
+ ignore_rest_of_line ();
+}
+
/* Get a string for the MRI IFC or IFNC pseudo-ops. */
static char *
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/doc/as.texinfo 2005-04-13 15:09:21.000000000 +0200
+++ 2005-04-26/gas/doc/as.texinfo 2005-04-27 11:37:16.000000000 +0200
@@ -4456,6 +4456,10 @@ Assembles the following section of code
has been defined. Note a symbol which has been referenced but not yet defined
is considered to be undefined.
+@cindex @code{ifb} directive
+@item .ifb @var{text}
+Assembles the following section of code if the operand is blank (empty).
+
@cindex @code{ifc} directive
@item .ifc @var{string1},@var{string2}
Assembles the following section of code if the two strings are the same. The
@@ -4490,6 +4494,11 @@ to zero.
@item .iflt @var{absolute expression}
Assembles the following section of code if the argument is less than zero.
+@cindex @code{ifnb} directive
+@item .ifnb @var{text}
+Like @code{.ifb}, but the sense of the test is reversed: this assembles the
+following section of code if the operand is non-blank (non-empty).
+
@cindex @code{ifnc} directive
@item .ifnc @var{string1},@var{string2}.
Like @code{.ifc}, but the sense of the test is reversed: this assembles the
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/read.c 2005-04-15 11:46:43.000000000 +0200
+++ 2005-04-26/gas/read.c 2005-04-27 11:37:16.000000000 +0200
@@ -342,6 +342,7 @@ static const pseudo_typeS potable[] = {
{"globl", s_globl, 0},
{"hword", cons, 2},
{"if", s_if, (int) O_ne},
+ {"ifb", s_ifb, 1},
{"ifc", s_ifc, 0},
{"ifdef", s_ifdef, 0},
{"ifeq", s_if, (int) O_eq},
@@ -350,6 +351,7 @@ static const pseudo_typeS potable[] = {
{"ifgt", s_if, (int) O_gt},
{"ifle", s_if, (int) O_le},
{"iflt", s_if, (int) O_lt},
+ {"ifnb", s_ifb, 0},
{"ifnc", s_ifc, 1},
{"ifndef", s_ifdef, 1},
{"ifne", s_if, (int) O_ne},
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/read.h 2005-03-04 15:51:40.000000000 +0100
+++ 2005-04-26/gas/read.h 2005-04-27 11:37:16.000000000 +0200
@@ -158,6 +158,7 @@ extern void s_func (int);
extern void do_s_func (int, const char *);
extern void s_globl (int arg);
extern void s_if (int arg);
+extern void s_ifb (int arg);
extern void s_ifc (int arg);
extern void s_ifdef (int arg);
extern void s_ifeqs (int arg);
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/testsuite/gas/all/cond.d 2001-03-31 08:47:54.000000000 +0200
+++ 2005-04-26/gas/testsuite/gas/all/cond.d 2005-04-26 17:33:32.000000000 +0200
@@ -23,8 +23,18 @@
27[ ]+.elseif 1
29[ ]+.else
31[ ]+.endif
- 32 000c 00 ?00 ?00 ?00[ ]+.p2align 5,0
- 32[ ]+00 ?00 ?00 ?00
- 32[ ]+00 ?00 ?00 ?00
- 32[ ]+00 ?00 ?00 ?00
- 32[ ]+00 ?00 ?00 ?00
+[ ]*[1-9][0-9]*[ ]+
+[ ]*[1-9][0-9]*[ ]+\.macro[ ]+m[ ]+x,[ ]*y[ ]*
+#...
+[ ]*[1-9][0-9]*[ ]+\.endm[ ]*
+[ ]*[1-9][0-9]*[ ]+[0-9a-f]+[048c] FF ?FF ?FF ?FF[ ]+m[ ]+,[ ]*
+[ ]*[1-9][0-9]*[ ]+FF ?FF ?FF ?FF[ ]*
+[ ]*[1-9][0-9]*[ ]+[0-9a-f]+[048c] FF ?FF ?FF ?FF[ ]+m[ ]+,[ ]*10[ ]*
+[ ]*[1-9][0-9]*[ ]+0[0A] ?00 ?00 ?0[0A][ ]*
+[ ]*[1-9][0-9]*[ ]+[0-9a-f]+[048c] 0[0B] ?00 ?00 ?0[0B][ ]+m[ ]+11,[ ]*
+[ ]*[1-9][0-9]*[ ]+FF ?FF ?FF ?FF[ ]*
+[ ]*[1-9][0-9]*[ ]+[0-9a-f]+[048c] 0[0C] ?00 ?00 ?0[0C][ ]+m[ ]+12,[ ]*13[ ]*
+[ ]*[1-9][0-9]*[ ]+0[0D] ?00 ?00 ?0[0D][ ]*
+[ ]*[1-9][0-9]*[ ]+
+[ ]*[1-9][0-9]*[ ]+.*\.p2align 5,0
+#pass
--- /home/jbeulich/src/binutils/mainline/2005-04-26/gas/testsuite/gas/all/cond.s 2001-03-31 08:47:54.000000000 +0200
+++ 2005-04-26/gas/testsuite/gas/all/cond.s 2005-04-26 17:19:49.000000000 +0200
@@ -29,4 +29,22 @@
.else
.long 9
.endif
+
+ .macro m x, y
+ .ifb \x
+ .long -1
+ .else
+ .long \x
+ .endif
+ .ifnb \y
+ .long \y
+ .else
+ .long -1
+ .endif
+ .endm
+ m ,
+ m , 10
+ m 11,
+ m 12, 13
+
.p2align 5,0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] new pseudo-ops .ifb/.ifnb
2005-04-28 8:18 [PATCH] new pseudo-ops .ifb/.ifnb Jan Beulich
@ 2005-04-28 15:17 ` Ian Lance Taylor
2005-05-05 9:58 ` Nick Clifton
1 sibling, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2005-04-28 15:17 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
"Jan Beulich" <JBeulich@novell.com> writes:
> In preparation of adding support for macros with variable number of
> arguments, this adds new conditional pseudo-op .ifb and .ifnb, which
> check whether their arguments are (non-)blank / (non-)empty.
I believe you can do that with .ifc and .ifnc, just by comparing to an
empty string.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] new pseudo-ops .ifb/.ifnb
2005-04-28 8:18 [PATCH] new pseudo-ops .ifb/.ifnb Jan Beulich
2005-04-28 15:17 ` Ian Lance Taylor
@ 2005-05-05 9:58 ` Nick Clifton
1 sibling, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2005-05-05 9:58 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
Hi Jan.
> gas/
> 2005-04-27 Jan Beulich <jbeulich@novell.com>
>
> * cond.c (s_ifb): New.
> * read.c (potable): Add s_ifb as handler for .ifb and .ifnb.
> * read.h (s_ifb): Prototype.
> * doc/as.texinfo: Document .ifb and .ifnb.
>
> gas/testsuite/
> 2005-04-27 Jan Beulich <jbeulich@novell.com>
>
> * gas/all/cond.s: Also test .ifb/.ifnb.
> * gas/all/cond.d: Adjust.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] new pseudo-ops .ifb/.ifnb
@ 2005-04-28 15:56 Jan Beulich
0 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2005-04-28 15:56 UTC (permalink / raw)
To: ian; +Cc: binutils
>>> Ian Lance Taylor <ian@airs.com> 28.04.05 16:29:37 >>>
>"Jan Beulich" <JBeulich@novell.com> writes:
>
>> In preparation of adding support for macros with variable number of
>> arguments, this adds new conditional pseudo-op .ifb and .ifnb, which
>> check whether their arguments are (non-)blank / (non-)empty.
>
>I believe you can do that with .ifc and .ifnc, just by comparing to an
>empty string.
In most cases, but not in all. This is because of the special treatment of certain characters in get_mri_string (i.e. comma, semicolon) without respecting quotation, and the unability to use single quoted strings on some (most?) targets (x86 is what I'm testing with).
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-05-05 9:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-28 8:18 [PATCH] new pseudo-ops .ifb/.ifnb Jan Beulich
2005-04-28 15:17 ` Ian Lance Taylor
2005-05-05 9:58 ` Nick Clifton
2005-04-28 15:56 Jan Beulich
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).