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]

Re: naked function attribute support for Mips


2013/5/3 reed kotler <rkotler@mips.com>:
> This issue of naked function attribute support for Mips has come up in the
> context of LLVM and in regards to maintaining compatibility with gcc.
>
> It's my understanding that the idea of the naked function attribute was
> rejected for gcc Mips.
>
> I'm curious as to why.

Because there is no 'naked' attribute spec for mips porting in gcc.
Refer to gcc/config/mips/mips.c:

  668 static const struct attribute_spec mips_attribute_table[] = {
  669   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
  670        om_diagnostic } */
  671   { "long_call",   0, 0, false, true,  true,  NULL, false },
  672   { "far",         0, 0, false, true,  true,  NULL, false },
  673   { "near",        0, 0, false, true,  true,  NULL, false },
  674   /* We would really like to treat "mips16" and "nomips16" as type
  675      attributes, but GCC doesn't provide the hooks we need to support
  676      the right conversion rules.  As declaration attributes, they affect
  677      code generation but don't carry other semantics.  */
  678   { "mips16",      0, 0, true,  false, false, NULL, false },
  679   { "nomips16",    0, 0, true,  false, false, NULL, false },
  680   { "micromips",   0, 0, true,  false, false, NULL, false },
  681   { "nomicromips", 0, 0, true,  false, false, NULL, false },
  682   { "nocompression", 0, 0, true,  false, false, NULL, false },
  683   /* Allow functions to be specified as interrupt handlers */
  684   { "interrupt",   0, 0, false, true,  true, NULL, false },
  685   { "use_shadow_register_set",  0, 0, false, true,  true, NULL, false },
  686   { "keep_interrupts_masked",   0, 0, false, true,  true, NULL, false },
  687   { "use_debug_exception_return", 0, 0, false, true,  true, NULL, false },
  688   { NULL,          0, 0, false, false, false, NULL, false }
  689 };

Generally, 'naked' attribute is used for interrupt handler
because we don't want compiler to generate prologue/epilogue.
Since mips already provides attributes to handle interrupt handler,
it is trivial to have 'naked' one.

Or do you think 'naked' is still useful for some other cases in mips porting?
You can implement it and submit the patch to gcc-patches@gcc.gnu.org
and I believe the mips maintainers are willing to have review with you. :)


Best regards,
jasonwucj

>
> For LLVM it basically works just by nature of how LLVM works in its target
> independent part.
>
> It will not emit the function prologue or epilogue.
>
> It still emits the .frame, .mask and .fmask because that is Mips specific
> code that does not currently know about the naked function attribute, but
> that is a separate issue.
>
> There is also the issue of the return statement but this also a separate non
> Mips specific issue and I will post that separately.
>
> Tia.
>
> Reed
>
>
>


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