Faith Ekstrand
82776f3882
nak/calc_instr_deps: Account for bindless CBufs
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
0c0cb4b9e9
nak/dce: Account for bindless CBuf handles
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
40a5b83cb3
nak/sm70: Properly encode bindless cbufs
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
d09d3f5246
nak/from_nir: Emit uniform instructions when !divergent
...
The really tricky case here is phis, which may have a uniform def even
though some of the srcs are non-uniform. This happens because of the
restriction elsewhere that requires UGPRs and UPreds to only ever be
written in uniform control-flow.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
3dfd92888a
nak: Add a UniformBuilder
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
ab8a4d1940
nak/from_nir: Clean up phi annotations
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
b013d54e4f
nak/lower_cf: Flag phis as convergent when possible
...
Because we go in and out of SSA, all the phis get re-created and the new
phis will default to divergent. This little pass attempts to prove as
many of the phis convergent as possible.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
06902bf52e
nak: Convert to LCSSA before divergence analysis
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
3528a0760c
nak/lower_cf: Track block divergence
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
0782087b8b
nak/lower_cf: Parent scopes are never NULL
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
29aad97279
nak/copy_prop: Don't propagate UBOs into uniform instructions
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
5406cfc7fe
nak/copy_prop: Rewrap a couple comments
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
81288bfad7
nak: Add a opt_uniform_instrs() pass
...
This both lowers away invalid uniform instructions and tries to optimize
things a bit so we don't end up with more R2UR than necessary.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
be91c321c9
nak/calc_instr_deps: Add latencies for uniform instructions
...
We know this is wrong. In many cases, they're faster than warp
instructions, sometimes with a latency as low as 2. However, there seem
to be a bunch of exceptions we don't understand and it's better to be
more concervative and have correct shaders.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
2d4e445099
nak/calc_instr_deps: Rewrite calc_delays() again
...
This time we take into account WaR and WaW dependencies and not just RaW
dependencies. The NVIDIA ISA is actually quite dynamic and the not
everything is nicely pipelined such that writes always happen at
consistent cycles. There are exact rules, of course, but we don't know
what those are so we need to make some worst-case assumptions.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
434af5b98b
nak/calc_instr_deps: Rename a couple variables
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
b47b8643b7
nak/legalize: Explicitly ignore OpPhiSrcs and OpPhiDsts
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
66a5608c11
nak/legalize: Uniform instructions can't have cbuf sources
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
7efc113bfe
nak/legalize: Copy uniform vectors in non-uniform control-flow
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
e4df28ade8
nak/legalize: Ensure all SSA values for a given ref are in the same file
...
It's possible for copy propagation to put a GPR and a UGPR into the same
vector source in an instruction. Hardware registers, however, are
either GPRs or UGPRs and never a mix.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
caf033b142
nak/legalize: Handle uniform sources in warp instructions
...
UGPRs in warp instructions are treated more like cbufs than GPRs.
You're only allowed to have one and it has to share space with the
possible cbuf or immediate. This means we need to treat them as a "not
a register" case for warp instructions but as a register for uniform
instructions.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
6ad49ca7d0
nak/legalize: Patch a RegFile through to copy helpers
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
c83593b07e
nak/legalize: Fix imad and ffma legalization on SM50
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
d9422a0897
nak/legalize: Be more precise about shfl and out
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
c1203ef5d1
nak/legalize: Drop some pointless plop3 logic
...
There is no restrictions on plop3 in terms of what sources can be
immediates vs. registers. Also, since we fold constants, all of this
code is dead.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
37b55ee34f
nak/legalize: Fold immediate sources before instructions
...
This way, if we insert a copy to move the immediate to a GPR, the
immediate we place in the copy is also folded.
Fixes: 85462f7455 ("nak: Legalize immediates with source modifiers")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
00c6244ca2
nak/sm70: Implement a bunch of uniform ops on SM75+
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
7359c214b7
nak/sm70: Fix encoding of fadd/fsetp and friends with UGPRs
...
UGPRs are treated more like CBufs or immediates so we want to use the
default encoding in the UGPR case and only use the reg encoding in the
zero or GPR case.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
21b1eb8da7
nak/sm70: Add support for encoding uniform ALU ops
...
This requires a pretty significant rework of encode_alu_base(). In
particular, we can't know the register file that's going to be used
until we get into encode_alu_base() so ALUSrc::from_src() can't handle
Zero itself. Instead, we defer to a new ALUSrc::with_op_uniformity()
helper which does a postprocess step.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
8d2d2db6a0
nak/sm70: Rework ALU source encode helpers
...
We have a LOT of repeated bit numbers here and it helps if we can reduce
that a bit by making helpers for each thing.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
1ae83135af
nak/sm70: Defer ALU src processing until encode_alu()
...
This makes encode_alu() take Option<&Src> and call ALUSrc::from_src()
itself. This is necessary for handling uniform ALU correctly as we
can't actually separate Reg from UReg without knowing what kind of ALU
op we are. While we're here, take an Option<&Dst> instead of
Option<Dst>.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
e244f7bb44
nak: Support uniform regs in lower_copy_swap()
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
130392e7ab
nak/ra: Never move uniform regs in non-uniform blocks
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
11670be661
nak/ra: Spill UGPRs and UPreds
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
1334cf8fca
nak/to_cssa: Resolve phi register file mismatches
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
1ed59706ea
nak: Add a concept of uniform blocks
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
d7f544365d
nak: Drop BasicBlock::new()
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
f0ec1873df
nak: Make SSARef::file() return Option<RegFile>
...
Once we start using UGPRs, it's possible to have a vector with a mix of
GPRs and UGPRs. This isn't actually allowed by the hardware but it's
possible as an intermediate state thanks to copy-propagation.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
d3e9373a90
nak/ra: Move an assert
...
We're allocating one register file at a time and our invariants are
per-file so we don't want to check the components assumption until we've
checked that it uses the active file.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
e0b051da39
nak: Clean up bindless cbuf handles
...
Take an SSARef instead of an SSAValue because they need to be vec2s.
Also, rename BindlessGPR to BindlessUGPR because that's what it is.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
35b445ba27
nak: Add OpR2UR
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
ebd16d1a56
nak: Add some helpers for uniform instructions and registers
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
0f70b14d9a
nak: Expose a BasicBlock::map_instrs() helper
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
fe2b06395e
nak: Get rid of OpINeg
...
Instead, do the same thing we do for float modifiers and use OpIAdd2 or
OpIAdd3. This makes for a little more work in copy-prop but the extra
opcode and lowering pass just isn't worth it.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
a08f8c8804
nak: Only copy-prop neg into iadd2/3 if no carry is written
...
Fixes: 1b3382b861 ("nak: Add modifier propagation")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
0a089b1b13
nak: BMov is always variable-latency
...
The barrier half is HW scoreboarded by the GPR isn't. When moving from
a GPR to a barrier, we still need a token for WaR hazards.
Fixes: 7cd9680554 ("nak: Add back OpBMov with better semantics")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
61be2c94dc
nak: Fix BasicBlock::phi*() for OpAnnotate
...
They assumed that phis would be at the start of the block which isn't
true if there are annotations in the way.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
944365802f
nak: Only convert the written portion of the buffer in NirInstrPrinter
...
Fixes: 02774be708 ("nak/sm50: add a memstream abstraction")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:45 +00:00
Faith Ekstrand
70b381e928
nak: Fix NAK_DEBUG=serial for warp barriers
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:44 +00:00
Faith Ekstrand
290cbf413c
nir/print: Improve divergence information
...
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591 >
2024-06-13 20:43:44 +00:00