nouveau/push: Make P_IMMD more versatile

It's now able to use either the immediate form or method form depending
on whether or not the value fits into 13 bits.  We wrap the check with
__builtin_constant_p() so that this choice is compile-time determined
instead of runtime.  I've verified with SET_CT_SELECT() that GCC is able
to determine which bits are used even if not all of them are constants.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:11:52 -06:00 committed by Marge Bot
parent ec0b9109b8
commit 4a22e24e98

View file

@ -66,20 +66,27 @@ __push_verify(struct nouveau_ws_push *push)
}
static inline void
__push_mthd(struct nouveau_ws_push *push, int subc, uint32_t mthd)
__push_mthd_size(struct nouveau_ws_push *push,
int subc, uint32_t mthd, unsigned size)
{
__push_verify(push);
push->last_size = push->map;
*push->map = NVC0_FIFO_PKHDR_SQ(subc, mthd, 0);
*push->map = NVC0_FIFO_PKHDR_SQ(subc, mthd, size);
push->map++;
}
static inline void
__push_mthd(struct nouveau_ws_push *push, int subc, uint32_t mthd)
{
__push_mthd_size(push, subc, mthd, 0);
}
#define P_MTHD(push, class, mthd) __push_mthd(push, SUBC_##class, class##_##mthd)
static inline uint32_t
NVC0_FIFO_PKHDR_IL(int subc, int mthd, uint16_t data)
{
assert(data < 0x2000);
assert(!(data & ~0x1fff));
return 0x80000000 | (data << 16) | (subc << 13) | (mthd >> 2);
}
@ -92,11 +99,17 @@ __push_immd(struct nouveau_ws_push *push, int subc, uint32_t mthd, uint32_t val)
push->map++;
}
#define P_IMMD(push, class, mthd, args...) do {\
uint32_t __val; \
VA_##class##_##mthd(__val, args); \
__push_immd(push, SUBC_##class, class##_##mthd, __val); \
} while(0)
#define P_IMMD(push, class, mthd, args...) do { \
uint32_t __val; \
VA_##class##_##mthd(__val, args); \
if (__builtin_constant_p(__val & ~0x1fff) && !(__val & ~0x1fff)) { \
__push_immd(push, SUBC_##class, class##_##mthd, __val); \
} else { \
__push_mthd_size(push, SUBC_##class, class##_##mthd, 1); \
*push->map = __val; \
push->map++; \
} \
} while(0)
static inline uint32_t
NVC0_FIFO_PKHDR_1I(int subc, int mthd, unsigned size)