This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

"cc" clobber


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' "cc" handling.

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.

Hmm.

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);
    clobber_rvec.safe_push (x);

    x = gen_rtx_REG (CCFPmode, FPSR_REG);
clobber_rvec.safe_push (x);
#endif
  }

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?

dw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]