diff options
Diffstat (limited to 'ptx/src/ast.rs')
-rw-r--r-- | ptx/src/ast.rs | 81 |
1 files changed, 17 insertions, 64 deletions
diff --git a/ptx/src/ast.rs b/ptx/src/ast.rs index 367f060..aba6bda 100644 --- a/ptx/src/ast.rs +++ b/ptx/src/ast.rs @@ -557,7 +557,7 @@ pub enum Instruction<P: ArgParams> { Mul(MulDetails, Arg3<P>), Add(ArithDetails, Arg3<P>), Setp(SetpData, Arg4Setp<P>), - SetpBool(SetpBoolData, Arg5<P>), + SetpBool(SetpBoolData, Arg5Setp<P>), Not(BooleanType, Arg2<P>), Bra(BraData, Arg1<P>), Cvt(CvtDetails, Arg2<P>), @@ -614,16 +614,12 @@ pub struct CallInst<P: ArgParams> { pub uniform: bool, pub ret_params: Vec<P::Id>, pub func: P::Id, - pub param_list: Vec<P::CallOperand>, + pub param_list: Vec<P::Operand>, } pub trait ArgParams { type Id; type Operand; - type IdOrVector; - type OperandOrVector; - type CallOperand; - type SrcMemberOperand; } pub struct ParsedArgParams<'a> { @@ -633,10 +629,6 @@ pub struct ParsedArgParams<'a> { impl<'a> ArgParams for ParsedArgParams<'a> { type Id = &'a str; type Operand = Operand<&'a str>; - type CallOperand = CallOperand<&'a str>; - type IdOrVector = IdOrVector<&'a str>; - type OperandOrVector = OperandOrVector<&'a str>; - type SrcMemberOperand = (&'a str, u8); } pub struct Arg1<P: ArgParams> { @@ -648,45 +640,32 @@ pub struct Arg1Bar<P: ArgParams> { } pub struct Arg2<P: ArgParams> { - pub dst: P::Id, + pub dst: P::Operand, pub src: P::Operand, } pub struct Arg2Ld<P: ArgParams> { - pub dst: P::IdOrVector, + pub dst: P::Operand, pub src: P::Operand, } pub struct Arg2St<P: ArgParams> { pub src1: P::Operand, - pub src2: P::OperandOrVector, -} - -pub enum Arg2Mov<P: ArgParams> { - Normal(Arg2MovNormal<P>), - Member(Arg2MovMember<P>), -} - -pub struct Arg2MovNormal<P: ArgParams> { - pub dst: P::IdOrVector, - pub src: P::OperandOrVector, + pub src2: P::Operand, } -// We duplicate dst here because during further compilation -// composite dst and composite src will receive different ids -pub enum Arg2MovMember<P: ArgParams> { - Dst((P::Id, u8), P::Id, P::Id), - Src(P::Id, P::SrcMemberOperand), - Both((P::Id, u8), P::Id, P::SrcMemberOperand), +pub struct Arg2Mov<P: ArgParams> { + pub dst: P::Operand, + pub src: P::Operand, } pub struct Arg3<P: ArgParams> { - pub dst: P::Id, + pub dst: P::Operand, pub src1: P::Operand, pub src2: P::Operand, } pub struct Arg4<P: ArgParams> { - pub dst: P::Id, + pub dst: P::Operand, pub src1: P::Operand, pub src2: P::Operand, pub src3: P::Operand, @@ -699,7 +678,7 @@ pub struct Arg4Setp<P: ArgParams> { pub src2: P::Operand, } -pub struct Arg5<P: ArgParams> { +pub struct Arg5Setp<P: ArgParams> { pub dst1: P::Id, pub dst2: Option<P::Id>, pub src1: P::Operand, @@ -715,39 +694,13 @@ pub enum ImmediateValue { F64(f64), } -#[derive(Copy, Clone)] -pub enum Operand<ID> { - Reg(ID), - RegOffset(ID, i32), - Imm(ImmediateValue), -} - -#[derive(Copy, Clone)] -pub enum CallOperand<ID> { - Reg(ID), - Imm(ImmediateValue), -} - -pub enum IdOrVector<ID> { - Reg(ID), - Vec(Vec<ID>), -} - -pub enum OperandOrVector<ID> { - Reg(ID), - RegOffset(ID, i32), +#[derive(Clone)] +pub enum Operand<Id> { + Reg(Id), + RegOffset(Id, i32), Imm(ImmediateValue), - Vec(Vec<ID>), -} - -impl<T> From<Operand<T>> for OperandOrVector<T> { - fn from(this: Operand<T>) -> Self { - match this { - Operand::Reg(r) => OperandOrVector::Reg(r), - Operand::RegOffset(r, imm) => OperandOrVector::RegOffset(r, imm), - Operand::Imm(imm) => OperandOrVector::Imm(imm), - } - } + VecMember(Id, u8), + VecPack(Vec<Id>), } pub enum VectorPrefix { |