From: Michal Ludvig <mludvig@suse.cz>
To: Hans-Peter Nilsson <hp@bitrange.com>
Cc: binutils@sources.redhat.com
Subject: Re: [RFA] CFI improvements
Date: Wed, 21 May 2003 16:44:00 -0000 [thread overview]
Message-ID: <3ECBACDE.5030104@suse.cz> (raw)
In-Reply-To: <Pine.BSF.4.44.0305211102500.325-100000@dair.pair.com>
[-- Attachment #1: Type: text/plain, Size: 1085 bytes --]
Hans-Peter Nilsson told me that:
> On Wed, 21 May 2003, Michal Ludvig wrote:
>
>>Hans-Peter Nilsson told me that:
>>
>>>On Tue, 20 May 2003, Michal Ludvig wrote:
>>>
>>>>the attached patch adds some new features to the CFI engine:
>>>>- register names can start with '%' as requested by GCC guys.
>>>
>>>This should be handled by the target's tc_regname_to_dw2regnum,
>>>not in target-independent code. (No creeping ix86-isms, please.)
>>
>>No problem. Something like this?
>
> Oh, sorry: consider redefining tc_regname_to_dw2regnum to take a
> char ** and to handle incrementing it over the register name.
It's not good a idea because you couldn't pass constant strings to the
function then. Instead I added another parameter - pointer to 'int' -
that is filled with the number of characters used. If the 'size' is NULL
nothing bad happens - the value is simply ignored. After return size can
be used to adjust input_line_pointer.
Comments? Can I commit this version (Alan)?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz
[-- Attachment #2: gas-cfi-enh1-3.diff --]
[-- Type: text/plain, Size: 6743 bytes --]
2003-05-21 Michal Ludvig <mludvig@suse.cz>
* dw2gencfi.c (cfi_parse_arg): Allow registers in more
generic way. Remove special case for '%'-starting regnames.
* config/tc-i386.c (tc_x86_regname_to_dw2regnum): Allow
'%'-starting regnames.
* testsuite/gas/cfi/cfi-x86_64.s: Test register names
starting with '%' and shorter than 3 chars.
Index: dw2gencfi.c
===================================================================
RCS file: /cvs/src/src/gas/dw2gencfi.c,v
retrieving revision 1.4
diff -u -p -r1.4 dw2gencfi.c
--- dw2gencfi.c 21 May 2003 11:31:07 -0000 1.4
+++ dw2gencfi.c 21 May 2003 16:32:37 -0000
@@ -151,20 +151,15 @@ cfi_parse_arg (long *param, int resolver
retval = 1;
}
#ifdef tc_regname_to_dw2regnum
- else if (resolvereg && ((is_name_beginner (*input_line_pointer))
- || (*input_line_pointer == '%'
- && is_name_beginner (*(++input_line_pointer)))))
+ else if (resolvereg)
{
- char *name, c, *p;
-
- name = input_line_pointer;
- c = get_symbol_end ();
- p = input_line_pointer;
-
- if ((value = tc_regname_to_dw2regnum (name)) >= 0)
+ int size;
+
+ if ((value = tc_regname_to_dw2regnum (input_line_pointer, &size)) >= 0)
+ {
retval = 1;
-
- *p = c;
+ input_line_pointer += size;
+ }
}
#endif
else
Index: config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.139
diff -u -p -r1.139 tc-i386.c
--- config/tc-i386.c 20 May 2003 07:58:06 -0000 1.139
+++ config/tc-i386.c 21 May 2003 16:32:38 -0000
@@ -6329,10 +6329,11 @@ tc_x86_cfi_init (void)
}
unsigned long
-tc_x86_regname_to_dw2regnum (const char *regname)
+tc_x86_regname_to_dw2regnum (char *regname, int *size)
{
unsigned int regnum;
unsigned int regnames_count;
+ unsigned int percent_flag = 0, name_len;
char *regnames_32[] =
{
"eax", "ebx", "ecx", "edx",
@@ -6347,24 +6348,52 @@ tc_x86_regname_to_dw2regnum (const char
"r12", "r13", "r14", "r15",
"rip"
};
- char **regnames;
+ char **regnames, *p, c;
if (flag_code == CODE_64BIT)
{
regnames = regnames_64;
- regnames_count = sizeof (regnames_64);
+ regnames_count = sizeof (regnames_64) / sizeof (void*);
}
else
{
regnames = regnames_32;
- regnames_count = sizeof (regnames_32);
+ regnames_count = sizeof (regnames_32) / sizeof (void*);
}
+ percent_flag = (*regname == '%');
+ regname += percent_flag;
+
+ p = regname;
+ while ((*p >= 'a' && *p <= 'z')
+ || (*p >= 'A' && *p <= 'Z')
+ || (*p >= '0' && *p <= '9'))
+ p++;
+
+ /* Save char at *p only when it isn't \0. */
+ if (*p)
+ {
+ c = *p;
+ *p = 0;
+ }
+
+ name_len = p - regname;
+
for (regnum = 0; regnum < regnames_count; regnum++)
if (strcmp (regname, regnames[regnum]) == 0)
+ {
+ if (size)
+ *size = percent_flag + name_len;
+ if (c)
+ *p = c;
return regnum;
+ }
as_bad (_("unknown register name '%s'"), regname);
+ if (size)
+ *size = percent_flag + name_len;
+ if (c)
+ *p = c;
return -1;
}
@@ -6373,12 +6402,12 @@ tc_x86_frame_initial_instructions (void)
{
if (flag_code == CODE_64BIT)
{
- cfi_add_insn (CFA_def_cfa, tc_x86_regname_to_dw2regnum ("rsp"), 8);
- cfi_add_insn (CFA_offset, tc_x86_regname_to_dw2regnum ("rip"), -8);
+ cfi_add_insn (CFA_def_cfa, tc_x86_regname_to_dw2regnum ("rsp", NULL), 8);
+ cfi_add_insn (CFA_offset, tc_x86_regname_to_dw2regnum ("rip", NULL), -8);
}
else
{
- cfi_add_insn (CFA_def_cfa, tc_x86_regname_to_dw2regnum ("esp"), 4);
- cfi_add_insn (CFA_offset, tc_x86_regname_to_dw2regnum ("eip"), -4);
+ cfi_add_insn (CFA_def_cfa, tc_x86_regname_to_dw2regnum ("esp", NULL), 4);
+ cfi_add_insn (CFA_offset, tc_x86_regname_to_dw2regnum ("eip", NULL), -4);
}
}
Index: config/tc-i386.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.h,v
retrieving revision 1.40
diff -u -p -r1.40 tc-i386.h
--- config/tc-i386.h 20 May 2003 07:58:07 -0000 1.40
+++ config/tc-i386.h 21 May 2003 16:32:38 -0000
@@ -553,7 +553,8 @@ extern void sco_id PARAMS ((void));
extern void tc_x86_cfi_init PARAMS ((void));
#define tc_regname_to_dw2regnum tc_x86_regname_to_dw2regnum
-extern unsigned long tc_x86_regname_to_dw2regnum PARAMS ((const char *regname));
+extern unsigned long tc_x86_regname_to_dw2regnum PARAMS ((char *regname,
+ int *size));
#define tc_cfi_frame_initial_instructions tc_x86_frame_initial_instructions
extern void tc_x86_frame_initial_instructions PARAMS ((void));
Index: testsuite/gas/cfi/cfi-x86_64.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi-x86_64.d,v
retrieving revision 1.2
diff -u -p -r1.2 cfi-x86_64.d
--- testsuite/gas/cfi/cfi-x86_64.d 20 May 2003 14:31:44 -0000 1.2
+++ testsuite/gas/cfi/cfi-x86_64.d 21 May 2003 16:32:38 -0000
@@ -41,7 +41,7 @@ The section .eh_frame contains:
00000060 0000001c 00000064 FDE cie=00000000 pc=00000000..00000013
DW_CFA_advance_loc: 3 to 00000003
- DW_CFA_def_cfa_reg: r12
+ DW_CFA_def_cfa_reg: r8
DW_CFA_advance_loc: 15 to 00000012
DW_CFA_def_cfa_reg: r7
DW_CFA_nop
Index: testsuite/gas/cfi/cfi-x86_64.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi-x86_64.s,v
retrieving revision 1.1
diff -u -p -r1.1 cfi-x86_64.s
--- testsuite/gas/cfi/cfi-x86_64.s 20 May 2003 08:01:19 -0000 1.1
+++ testsuite/gas/cfi/cfi-x86_64.s 21 May 2003 16:32:38 -0000
@@ -35,9 +35,9 @@ func_prologue:
#; each instruction.
pushq %rbp
.cfi_def_cfa_offset 16
- .cfi_offset rbp,-16
+ .cfi_offset %rbp, -16
movq %rsp, %rbp
- .cfi_def_cfa_register rbp
+ .cfi_def_cfa_register %rbp
#; function body
call func_locvars
@@ -46,7 +46,7 @@ func_prologue:
#; epilogue with valid CFI
#; (we're better than gcc :-)
leaveq
- .cfi_def_cfa rsp,8
+ .cfi_def_cfa %rsp, 8
ret
.cfi_endproc
@@ -59,21 +59,21 @@ func_prologue:
func_otherreg:
.cfi_startproc
- #; save frame pointer to r12
- movq %rsp,%r12
- .cfi_def_cfa_register r12
+ #; save frame pointer to r8
+ movq %rsp,%r8
+ .cfi_def_cfa_register r8
#; alocate space for local vars
#; (no .cfi_{def,adjust}_cfa_offset here,
- #; because CFA is computed from r12!)
+ #; because CFA is computed from r8!)
sub $100,%rsp
#; function body
call func_prologue
addl $2, %eax
- #; restore frame pointer from r12
- movq %r12,%rsp
+ #; restore frame pointer from r8
+ movq %r8,%rsp
.cfi_def_cfa_register rsp
ret
.cfi_endproc
next prev parent reply other threads:[~2003-05-21 16:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-20 12:21 Michal Ludvig
2003-05-20 12:55 ` Andreas Jaeger
2003-05-20 12:57 ` Alan Modra
2003-05-20 13:10 ` Michal Ludvig
2003-05-20 13:55 ` Michal Ludvig
2003-05-20 14:18 ` Alan Modra
2003-05-20 14:36 ` Michal Ludvig
2003-05-20 23:54 ` Hans-Peter Nilsson
2003-05-21 13:18 ` Michal Ludvig
2003-05-21 14:35 ` Hans-Peter Nilsson
2003-05-21 15:06 ` Hans-Peter Nilsson
2003-05-21 16:44 ` Michal Ludvig [this message]
2003-05-21 16:52 ` Hans-Peter Nilsson
2003-05-27 12:34 ` amodra
2003-05-27 12:42 ` Michal Ludvig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ECBACDE.5030104@suse.cz \
--to=mludvig@suse.cz \
--cc=binutils@sources.redhat.com \
--cc=hp@bitrange.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).