Index: llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.td =================================================================== --- llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.td +++ llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.td @@ -1122,6 +1122,7 @@ field RegisterOperand Src1RC64 = getVOP3SrcForVT.ret; field RegisterOperand Src2RC64 = getVOP3SrcForVT.ret; + field bit HasDst32 = !if(!eq(DstVT, untyped), 0, 1); field int NumSrcArgs = getNumSrcArgs.ret; field bit HasModifiers = hasModifiers.ret; @@ -1210,6 +1211,8 @@ // an explicit $dst. class VOPC_Profile : VOPProfile <[i1, vt0, vt1, untyped]> { let Asm32 = "vcc, $src0, $src1"; + // The destination for 32-bit encoding is implicit. + let HasDst32 = 0; } class VOPC_Class_Profile : VOPC_Profile { @@ -1250,10 +1253,52 @@ def VOP_I32_I32_I32_I32 : VOPProfile <[i32, i32, i32, i32]>; def VOP_I64_I32_I32_I64 : VOPProfile <[i64, i32, i32, i64]>; -class SIInstAlias : InstAlias , - PredicateControl { +class SIInstAlias : + InstAlias , PredicateControl { + field bit isCompare; field bit isCommutable; + + let ResultInst = + !if (p.HasDst32, + !if (!eq(p.NumSrcArgs, 0), + // 1 dst, 0 src + (inst p.DstRC:$dst), + !if (!eq(p.NumSrcArgs, 1), + // 1 dst, 1 src + (inst p.DstRC:$dst, p.Src0RC32:$src0), + !if (!eq(p.NumSrcArgs, 2), + // 1 dst, 2 src + (inst p.DstRC:$dst, p.Src0RC32:$src0, p.Src1RC32:$src1), + // else - unreachable + (inst)))), + // else + !if (!eq(p.NumSrcArgs, 2), + // 0 dst, 2 src + (inst p.Src0RC32:$src0, p.Src1RC32:$src1), + !if (!eq(p.NumSrcArgs, 1), + // 0 dst, 1 src + (inst p.Src0RC32:$src1), + // else + // 0 dst, 0 src + (inst)))); +} + +class SIInstAliasSI : + SIInstAlias (op_name#"_e32_si"), p> { + let AssemblerPredicate = SIAssemblerPredicate; +} + +class SIInstAliasVI : + SIInstAlias (op_name#"_e32_vi"), p> { + let AssemblerPredicates = [isVI]; +} + +multiclass SIInstAliasBuilder { + + def : SIInstAliasSI ; + + def : SIInstAliasVI ; } class VOP { @@ -1712,11 +1757,6 @@ let SchedRW = sched; } - def : SIInstAlias < - alias_asm, - (!cast(NAME#"_e32_si") p.Src0RC32:$src0, p.Src1RC32:$src1) - >; - } // End AssemblerPredicates = [isSICI] let AssemblerPredicates = [isVI] in { @@ -1727,11 +1767,9 @@ let SchedRW = sched; } - def : SIInstAlias < - alias_asm, - (!cast(NAME#"_e32_vi") p.Src0RC32:$src0, p.Src1RC32:$src1) - >; } // End AssemblerPredicates = [isVI] + + defm : SIInstAliasBuilder; } multiclass VOPC_Helper