This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
New keywords (string32) for GNU as ?
- From: "Helge Deller" <deller at gmx dot de>
- To: binutils at sources dot redhat dot com
- Date: Sun, 19 Nov 2006 15:22:51 +0100
- Subject: New keywords (string32) for GNU as ?
gcc's assembler output for this C-Code:
static wchar_t x[] = L"HELLO";
is (on little endian targets) something like this:
x:
.string "H"
.string ""
.string ""
.string "E
.string ""
.string ""
.string "L"
.....
The patch below introduces a new keyword ".string32" to GNU as,
which creates the same code as the lines above with less commands:
x:
.string32 "HELLO"
Would this kind of new keyword "in principle" be acceptable for GNU as/binutils ?
Helge
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.121
diff -u -p -r1.121 read.c
--- gas/read.c 29 Aug 2006 15:19:43 -0000 1.121
+++ gas/read.c 19 Nov 2006 13:59:21 -0000
@@ -408,6 +408,9 @@ static const pseudo_typeS potable[] = {
{"stabn", s_stab, 'n'},
{"stabs", s_stab, 's'},
{"string", stringer, 1},
+ {"string8", stringer, 1},
+ {"string16", stringer, 16+1},
+ {"string32", stringer, 32+1},
{"struct", s_struct, 0},
/* tag */
{"text", s_text, 0},
@@ -4654,6 +4657,30 @@ s_leb128 (int sign)
input_line_pointer--;
demand_empty_rest_of_line ();
}
+
+static void stringer_append_char( int c, int bitsize )
+{
+ if (bitsize == 8 || !target_big_endian)
+ FRAG_APPEND_1_CHAR(c);
+ switch (bitsize) {
+ case 8:
+ return;
+ case 32:
+ FRAG_APPEND_1_CHAR(0);
+ FRAG_APPEND_1_CHAR(0);
+ /* fall through */
+ case 16:
+ FRAG_APPEND_1_CHAR(0);
+ /* fall through */
+ default:
+ if (!target_big_endian)
+ return;
+ break;
+ }
+ /* on big endian append character */
+ FRAG_APPEND_1_CHAR(c);
+}
+
/* We read 0 or more ',' separated, double-quoted strings.
Caller should have checked need_pass_2 is FALSE because we don't
@@ -4662,9 +4689,10 @@ s_leb128 (int sign)
void
stringer (/* Worker to do .ascii etc statements. */
/* Checks end-of-line. */
- register int append_zero /* 0: don't append '\0', else 1. */)
+ register int bitsize_and_append_zero /* 0: don't append '\0', else 1. */)
{
register unsigned int c;
+ int bitsize = bitsize_and_append_zero & (8+16+32);
char *start;
#ifdef md_flush_pending_output
@@ -4704,11 +4732,11 @@ stringer (/* Worker to do .ascii etc sta
start = input_line_pointer;
while (is_a_char (c = next_char_of_string ()))
{
- FRAG_APPEND_1_CHAR (c);
+ stringer_append_char (c, bitsize);
}
- if (append_zero)
+ if (bitsize_and_append_zero & 1)
{
- FRAG_APPEND_1_CHAR (0);
+ stringer_append_char (0, bitsize);
}
know (input_line_pointer[-1] == '\"');
@@ -4736,7 +4764,7 @@ stringer (/* Worker to do .ascii etc sta
case '<':
input_line_pointer++;
c = get_single_number ();
- FRAG_APPEND_1_CHAR (c);
+ stringer_append_char (c, bitsize);
if (*input_line_pointer != '>')
{
as_bad (_("expected <nn>"));
--
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!