[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 19 12:12:04 PDT 2017

rjmccall added inline comments.

Comment at: include/clang/Basic/AttrDocs.td:1336
+if code compiled using ``-mlong-calls`` switch, it forces compiler to use
+the ``jal`` instruction to call the function.
+  }];
sdardis wrote:
> rjmccall wrote:
> > I suggest the following wording:
> > 
> > Clang supports the ``__attribute__((long_call))``, ``__attribute__((far))``, and
> > ``__attribute__((near))`` attributes on MIPS targets.  These attributes may only be
> > added to function declarations and change the code generated by the compiler when
> > directly calling the function.  The ``near`` attribute allows calls to the function to
> > be made using the ``jal`` instruction, which requires the function to be defined in the
> > same 256MB segment as the caller.  The ``long_call`` and ``far`` attributes are
> > synonyms and require the use of a different call sequence that works regardless of
> > the distance between the functions.
> > 
> > These attributes take priority over command line switches such as ``-mlong-calls``.
> > requires the function to be defined
> I'd change the "defined" to be "located".
> > in the same 256MB segment as the caller.
> I'd change this to: "in the same naturally aligned 256MB segment as the caller."
> This also needs a note saying that it has no effect for code compiled with -fpic.
Oh, yes, if these statements are true then it's absolutely important to include them.  I was going off of the raw ISA specification, since jal just takes a relative offset, but if the toolchain has more specific requirements then those are what should be documented.

This whole feature is strange to me; do MIPS linkers just never introduce things like branch islands and lazy-binding functions?



More information about the cfe-commits mailing list