[AMDGPU] Add MMOs for GFX11 Streamout Instructions
authorDiana Picus <Diana-Magda.Picus@amd.com>
Mon, 13 Mar 2023 15:37:44 +0000 (16:37 +0100)
committerDiana Picus <Diana-Magda.Picus@amd.com>
Tue, 11 Apr 2023 09:11:32 +0000 (11:11 +0200)
commitd9bf8aba2371c8deadfabe90d52431d4bb7ab6cc
tree846f059aa887785cf895b2749d383256521ee5c7
parentf8861ea023e72f93c0c7329996b8bea31b53f90e
[AMDGPU] Add MMOs for GFX11 Streamout Instructions

The GFX11 NGG Streamout Instructions perform atomic operations on
dedicated registers. At the moment, they lack machine memory operands,
which causes the si-memory-legalizer pass to treat them conservatively
and introduce several unnecessary waits and cache invalidations.

This patch introduces a new address space to represent these special
registers and teaches instruction selection to add memory operands with
this new address space to DS_ADD/SUB_GS_REG_RTN.

Since this address space is meant to be compiler-internal, we move it
up a bit from the other address spaces and give it the number 128.
According to the LLVM Language Reference, address space numbers can go
all the way up to 2^24, but I'm not sure how well this is supported in
practice [1], so using a smaller number seems safer.

[1] https://github.com/llvm/llvm-project/blob/0107513fe79da7670e37c29c0862794a2213a89c/llvm/utils/TableGen/IntrinsicEmitter.cpp#L401

Differential Revision: https://reviews.llvm.org/D146031
llvm/docs/AMDGPUUsage.rst
llvm/include/llvm/IR/IntrinsicsAMDGPU.td
llvm/lib/Target/AMDGPU/AMDGPU.h
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.add.gs.reg.rtn.ll
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.sub.gs.reg.rtn.ll