On Thu, Feb 25, 2021, at 10:57 AM, Maciej W. Rozycki wrote: > On Thu, 25 Feb 2021, Jiaxun Yang wrote: > > > > There is a far easier way to do this, which is to just emit an assembler > > > macro, and let the assembler generate the labels and relocs. This is what > > > the RISC-V GCC port does by default. This prevents some optimizations like > > > scheduling the two instructions, but enables some other optimizations like > > > loop unrolling. So it is a tossup. Sometimes we get better code with the > > > assembler macro, and sometimes we get better code by emitting the auipc and > > > addi separately. > > > > Thanks all, > > > > I'll take this approach first, add "lla, dlla" pseudo-instructions to > > assembler and seeking optimization > > in future. > > The DLA and LA macros are supposed to do that already, no need to invent > new names. Hmm, how could we tell if the symbol is local? Global symbols still needs to be load from GOT. I saw RISC-V dealt that by “lla” pesudo-op which indicate the symbol is local. > > They may not have been implemented for R6, but I'm not sure. There was > some resistance against macros at one point as the new generation came to > work on the MIPS assembler and consequently inconsistencies resulted in > the language that may not have b"en removed to date. > > In any case you need to use `-mno-explicit-relocs' with GCC then so as > not to break the compiler's semantics or assumptions. > > > Btw I found we don't have any document for MIPS pseudo-instructions. RISC-V > > put them in ISA manual > > but it is not the case for MIPS. Is it possible to have one in binutils? > > There are MIPS assembly language books available; I'm fairly sure Dominic > Sweetman's "See MIPS Run" has a chapter (I don't have the book at hand). > I don't think GNU binutils documentation is supposed to describe the > assembly dialects supported, except maybe for GNU extensions (pseudo-ops). Yeah I saw See MIPS Run, but it's not a mandatory specification. Without a specification we may have different implementation across toolchains and trouble users. Thanks. - Jiaxun > > Maciej > -- - Jiaxun