This is the mail archive of the
mailing list for the GCC project.
- From: David Wohlferd <dw at LimeGreenSocks dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 26 Jan 2016 15:12:09 -0800
- Subject: "cc" clobber
- Authentication-results: sourceware.org; auth=none
It is well known that on i386, the "cc" clobber is always set for
extended asm, whether it is specified or not. I was wondering how much
difference it might make if the generated code actually followed what
the user specified (expectation: not much). But implementing this
turned up a different question.
I started by just commenting out the code in ix86_md_asm_adjust that
unconditionally clobbered the flags. I figured this would allow the
'normal' "cc" handling to occur. But apparently there is no 'normal'
So I went back to ix86_md_asm_adjust and tried to handle the "cc" if it
was specified in the clobbers argument. But apparently "cc" doesn't get
added to that clobbers list.
Tracing back to see how the "memory" clobber (which does get added to
the clobber list) is handled brings me to expand_asm_stmt() in
cfgexpand.c. Following the example set by the memory clobber, it looks
like I want something like this:
else if (j == -3)
#if defined(__i386__) || defined(__x86_64__)
rtx x = gen_rtx_REG (CCmode, FLAGS_REG);
x = gen_rtx_REG (CCFPmode, FPSR_REG);
Now I can check for this in the clobbers to ix86_md_asm_adjust and
SET_HARD_REG_BIT as appropriate. Tada.
It's working, but can that be right? Why do I need to do this for
i386? How do other platforms handle "cc"?
Other than not rejecting it as an invalid clobber, I can't find any code
that seems to recognize "cc." Has "cc" become just an unenforced
comment on all platforms? Or did I just miss it?