PATCH: R600/SI: Experimental assembler / inline assembly support

Tom Stellard tom at stellard.net
Fri Mar 13 08:39:01 PDT 2015


On Fri, Mar 13, 2015 at 04:05:52PM +0100, Marek Olšák wrote:
> Hi Tom,
> 
> So will I be able to use inline assembly in Mesa? Can I write whole
> shaders in asm? Will the compilation be faster with asm-only shaders?
> 

Yes, there are a few things you can do:

1. Write shaders in assembly, assemble them during mesa build time and embed
the binary in the driver.

2. Embed the shader assembly strings in the driver and assemble them
during run-time.

3. Mix inline assembly in with LLVM IR, and compile them during runtime.

Doing 1 and 2 will make the compilation process much faster.   I'm not
sure if 3 will be faster even if the entire shader is inline assembly.

If you have any shaders that you think might be good candidates for one
of the methods, let me know and I can help make sure the assembler
supports the correct instructions.  The main thing missing right now is
MIMG instructions, but there may be bugs in assembling some other
instruction types.

You can find syntax examples in the llvm tree: test/MC/R600/*.s
and you can use the llvm-mc tool to assemble the shaders:

This command will output assembly text with the encoding,
which I use for testing:

llvm-mc -arch=amdgcn -mcpu=SI -show-encoding -o - asm.s

This command will assemble to binary:

llvm-mc -arch=amdgcn -mcpu=SI -filetype=obj -o - asm.o

Note that the assembler doesn't automatically emit information
about register usage.  You need to specify it in the assembler file.

Take a look at the output of the test/CodeGen/R600/elf.ll test to see
how to input this information into the file.  This will work for now,
but I'm working on an easier way to specify this information.

You can also invoke the assembler at runtime using the C API.

-Tom


> This would be useful for a fetch shader, which should be a separate
> binary invoked by a vertex shader (e.g. by using a jump instruction,
> or more easily, by appending a vertex shader binary after a fetch
> shader binary).
> 
> Marek
> 
> On Fri, Mar 13, 2015 at 3:45 AM, Tom Stellard <tom at stellard.net> wrote:
> > Hi,
> >
> > The attached patches add experimental assembler and inline assembly
> > support to the R600 backend.  Not all instructions are supported yet,
> > but the most of non-image instructions should work.
> >
> > I've only tested with the SI encodings, Sea Islands and Volcanic Islands
> > are probably less complete.
> >
> > -Tom
> >
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >




More information about the llvm-commits mailing list