aco: add get_const/is_constant_representable helpers
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7798>
This commit is contained in:
@@ -185,37 +185,18 @@ struct ssa_info {
|
||||
void set_constant(chip_class chip, uint64_t constant)
|
||||
{
|
||||
Operand op16((uint16_t)constant);
|
||||
Operand op32((uint32_t)constant);
|
||||
Operand op32 = Operand::get_const(chip, constant, 4);
|
||||
add_label(label_literal);
|
||||
val = constant;
|
||||
|
||||
if (chip >= GFX8 && !op16.isLiteral())
|
||||
add_label(label_constant_16bit);
|
||||
|
||||
if (!op32.isLiteral() || ((uint32_t)constant == 0x3e22f983 && chip >= GFX8))
|
||||
if (!op32.isLiteral())
|
||||
add_label(label_constant_32bit);
|
||||
|
||||
if (constant <= 64) {
|
||||
if (Operand::is_constant_representable(constant, 8))
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant >= 0xFFFFFFFFFFFFFFF0) { /* [-16 .. -1] */
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant == 0x3FE0000000000000) { /* 0.5 */
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant == 0xBFE0000000000000) { /* -0.5 */
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant == 0x3FF0000000000000) { /* 1.0 */
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant == 0xBFF0000000000000) { /* -1.0 */
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant == 0x4000000000000000) { /* 2.0 */
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant == 0xC000000000000000) { /* -2.0 */
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant == 0x4010000000000000) { /* 4.0 */
|
||||
add_label(label_constant_64bit);
|
||||
} else if (constant == 0xC010000000000000) { /* -4.0 */
|
||||
add_label(label_constant_64bit);
|
||||
}
|
||||
|
||||
if (label & label_constant_64bit) {
|
||||
val = Operand(constant).constantValue();
|
||||
@@ -809,15 +790,9 @@ unsigned get_operand_size(aco_ptr<Instruction>& instr, unsigned index)
|
||||
|
||||
Operand get_constant_op(opt_ctx &ctx, ssa_info info, uint32_t bits)
|
||||
{
|
||||
if (bits == 8)
|
||||
return Operand((uint8_t)info.val);
|
||||
if (bits == 16)
|
||||
return Operand((uint16_t)info.val);
|
||||
// TODO: this functions shouldn't be needed if we store Operand instead of value.
|
||||
Operand op(info.val, bits == 64);
|
||||
if (info.is_literal(32) && info.val == 0x3e22f983 && ctx.program->chip_class >= GFX8)
|
||||
op.setFixed(PhysReg{248}); /* 1/2 PI can be an inline constant on GFX8+ */
|
||||
return op;
|
||||
if (bits == 64)
|
||||
return Operand(info.val, true);
|
||||
return Operand::get_const(ctx.program->chip_class, info.val, bits / 8u);
|
||||
}
|
||||
|
||||
bool fixed_to_exec(Operand op)
|
||||
|
||||
Reference in New Issue
Block a user