mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-19 12:30:30 +01:00
nak: sm50: remove encode_alu() and friends
This method was too complex. Remove it as we have now rewritten all other methods not to rely on it. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26114>
This commit is contained in:
parent
f32c560e82
commit
592d8fa436
1 changed files with 0 additions and 159 deletions
|
|
@ -69,52 +69,6 @@ enum ALUSrc {
|
|||
CBuf(ALUCBufRef),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct ALUModifierInfo {
|
||||
abs_bit: Option<usize>,
|
||||
neg_bit: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct ALUSrcsModifier {
|
||||
src0_opt: Option<ALUModifierInfo>,
|
||||
src1_opt: Option<ALUModifierInfo>,
|
||||
src2_opt: Option<ALUModifierInfo>,
|
||||
}
|
||||
|
||||
enum ALUEncodingType {
|
||||
Variant1,
|
||||
Variant2,
|
||||
Variant3,
|
||||
Variant4,
|
||||
}
|
||||
|
||||
struct ALUEncodingInfo {
|
||||
opcode: u16,
|
||||
encoding_type: ALUEncodingType,
|
||||
reg_modifier: Option<ALUSrcsModifier>,
|
||||
imm24_modifier: Option<ALUSrcsModifier>,
|
||||
cbuf_modifier: Option<ALUSrcsModifier>,
|
||||
// TODO
|
||||
//imm32_modifier: Option<ALUSrcsModifier>,
|
||||
imm32_behavior_opt: Option<ALUImm32Behavior>,
|
||||
}
|
||||
|
||||
impl ALUEncodingInfo {
|
||||
fn get_modifier(&self, src1: &ALUSrc) -> Option<&ALUSrcsModifier> {
|
||||
match src1 {
|
||||
ALUSrc::Imm32(_) => self.imm24_modifier.as_ref(),
|
||||
ALUSrc::None | ALUSrc::Reg(_) => self.reg_modifier.as_ref(),
|
||||
ALUSrc::CBuf(_) => self.cbuf_modifier.as_ref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ALUImm32Behavior {
|
||||
opcode: u16,
|
||||
prefer_imm32: bool,
|
||||
}
|
||||
|
||||
fn src_mod_has_abs(src_mod: SrcMod) -> bool {
|
||||
match src_mod {
|
||||
SrcMod::None | SrcMod::FNeg | SrcMod::INeg | SrcMod::BNot => false,
|
||||
|
|
@ -507,119 +461,6 @@ impl SM50Instr {
|
|||
}
|
||||
}
|
||||
|
||||
fn encode_alu(
|
||||
&mut self,
|
||||
encoding_info: ALUEncodingInfo,
|
||||
dst: Option<Dst>,
|
||||
src0: ALUSrc,
|
||||
src1: ALUSrc,
|
||||
src2: ALUSrc,
|
||||
) -> bool {
|
||||
if let Some(dst) = dst {
|
||||
self.set_dst(dst);
|
||||
}
|
||||
|
||||
let (src0, src2) = if src0.is_none_or_reg_zero() && !src2.is_none() {
|
||||
(src2, src0)
|
||||
} else {
|
||||
(src0, src2)
|
||||
};
|
||||
|
||||
let modifier = encoding_info
|
||||
.get_modifier(&src1)
|
||||
.expect("Invalid src1 type");
|
||||
|
||||
let src0_abs_bit = modifier.src0_opt.as_ref().and_then(|x| x.abs_bit);
|
||||
let src0_neg_bit = modifier.src0_opt.as_ref().and_then(|x| x.neg_bit);
|
||||
let src1_abs_bit = modifier.src1_opt.as_ref().and_then(|x| x.abs_bit);
|
||||
let src1_neg_bit = modifier.src1_opt.as_ref().and_then(|x| x.neg_bit);
|
||||
let src2_abs_bit = modifier.src2_opt.as_ref().and_then(|x| x.abs_bit);
|
||||
let src2_neg_bit = modifier.src2_opt.as_ref().and_then(|x| x.neg_bit);
|
||||
|
||||
self.set_alu_reg_src(8..16, src0_abs_bit, src0_neg_bit, &src0);
|
||||
let form = match &src1 {
|
||||
ALUSrc::Reg(reg1) => {
|
||||
match &src2 {
|
||||
ALUSrc::None => {
|
||||
self.set_alu_reg(
|
||||
20..28,
|
||||
src1_abs_bit,
|
||||
src1_neg_bit,
|
||||
reg1,
|
||||
);
|
||||
}
|
||||
ALUSrc::Reg(reg2) => {
|
||||
self.set_alu_reg(
|
||||
20..28,
|
||||
src1_abs_bit,
|
||||
src1_neg_bit,
|
||||
reg1,
|
||||
);
|
||||
self.set_alu_reg(
|
||||
39..47,
|
||||
src2_abs_bit,
|
||||
src2_neg_bit,
|
||||
reg2,
|
||||
);
|
||||
}
|
||||
ALUSrc::Imm32(imm) => {
|
||||
panic!("src2 cannot be of type Imm32!")
|
||||
}
|
||||
ALUSrc::CBuf(cb) => {
|
||||
// TODO: Check if that truely don't exist.
|
||||
panic!("src2 cannot be of type cbuf!")
|
||||
}
|
||||
}
|
||||
|
||||
match encoding_info.encoding_type {
|
||||
ALUEncodingType::Variant1 => 0x58,
|
||||
ALUEncodingType::Variant2 => 0x5a,
|
||||
ALUEncodingType::Variant3 => 0x5b,
|
||||
ALUEncodingType::Variant4 => 0x5c,
|
||||
}
|
||||
}
|
||||
ALUSrc::Imm32(imm) => {
|
||||
// FIXME: There is no encoding for 3 sources.
|
||||
assert!(src2.is_none_or_reg_zero());
|
||||
|
||||
if let Some(imm32_behavior) = encoding_info.imm32_behavior_opt {
|
||||
if imm32_behavior.prefer_imm32 || *imm > 0xfffff {
|
||||
self.set_opcode(imm32_behavior.opcode);
|
||||
self.set_src_imm32(20..52, *imm);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
self.set_src_imm_i20(20..39, 56, *imm);
|
||||
|
||||
match encoding_info.encoding_type {
|
||||
ALUEncodingType::Variant1 => 0x30,
|
||||
ALUEncodingType::Variant2 => 0x34,
|
||||
ALUEncodingType::Variant3 => 0x36,
|
||||
ALUEncodingType::Variant4 => 0x38,
|
||||
}
|
||||
}
|
||||
ALUSrc::CBuf(cb) => {
|
||||
self.set_alu_cb(20..39, src1_abs_bit, src1_neg_bit, cb);
|
||||
self.set_alu_reg_src(39..47, src2_abs_bit, src2_neg_bit, &src2);
|
||||
|
||||
match encoding_info.encoding_type {
|
||||
ALUEncodingType::Variant1 => 0x48,
|
||||
ALUEncodingType::Variant2 => 0x4a,
|
||||
ALUEncodingType::Variant3 => 0x4b,
|
||||
ALUEncodingType::Variant4 => 0x4c,
|
||||
}
|
||||
}
|
||||
_ => panic!("Invalid instruction form"),
|
||||
};
|
||||
|
||||
self.set_field(48..56, encoding_info.opcode);
|
||||
self.set_field(56..64, form);
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn encode_mov(&mut self, op: &OpMov) {
|
||||
match &op.src.src_ref {
|
||||
SrcRef::Zero | SrcRef::Reg(_) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue