Skip to content

Commit

Permalink
R600/SI: Refactor VOP3 instruction definitions
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213571 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
tstellarAMD committed Jul 21, 2014
1 parent 3ee2c33 commit 163d8ce
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 21 deletions.
2 changes: 2 additions & 0 deletions lib/Target/R600/SIInstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class VOP3Common <dag outs, dag ins, string asm, list<dag> pattern> :
let hasSideEffects = 0;
let UseNamedOperandTable = 1;
let VOP3 = 1;

int Size = 8;
}

//===----------------------------------------------------------------------===//
Expand Down
71 changes: 50 additions & 21 deletions lib/Target/R600/SIInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,54 @@ class SIMCInstr <string pseudo, int subtarget> {
int Subtarget = subtarget;
}

class VOP3_Pseudo <dag outs, dag ins, list<dag> pattern, string opName> :
VOP3Common <outs, ins, "", pattern>,
VOP <opName>,
SIMCInstr<opName, SISubtarget.NONE> {
let isPseudo = 1;
}

class VOP3_Real_si <bits<9> op, dag outs, dag ins, string asm, string opName> :
VOP3 <op, outs, ins, asm, []>,
SIMCInstr<opName, SISubtarget.SI>;

multiclass VOP3_m <bits<9> op, dag outs, dag ins, string asm, list<dag> pattern,
string opName> {

def "" : VOP3Common <outs, ins, "", pattern>, VOP <opName>,
SIMCInstr<OpName, SISubtarget.NONE> {
let isPseudo = 1;
}
def "" : VOP3_Pseudo <outs, ins, pattern, opName>;

def _si : VOP3_Real_si <op, outs, ins, asm, opName>;

}

multiclass VOP3_1_m <bits<8> op, dag outs, dag ins, string asm,
list<dag> pattern, string opName> {

def "" : VOP3_Pseudo <outs, ins, pattern, opName>;

let src1 = 0, src1_modifiers = 0, src2 = 0, src2_modifiers = 0 in {

def _si : VOP3_Real_si <
{1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
outs, ins, asm, opName
>;

} // src1 = 0, src1_modifiers = 0, src2 = 0, src2_modifiers = 0
}

multiclass VOP3_2_m <bits<6> op, dag outs, dag ins, string asm,
list<dag> pattern, string opName, string revOp> {

def _si : VOP3 <op, outs, ins, asm, []>, SIMCInstr<opName, SISubtarget.SI>;
def "" : VOP3_Pseudo <outs, ins, pattern, opName>;

let src2 = 0, src2_modifiers = 0 in {

def _si : VOP3_Real_si <
{1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
outs, ins, asm, opName>,
VOP2_REV<revOp#"_e64", !eq(revOp, opName)>;

} // src2 = 0, src2_modifiers = 0
}

// This must always be right before the operand being input modified.
Expand All @@ -309,17 +347,11 @@ multiclass VOP1_Helper <bits<8> op, RegisterClass drc, RegisterClass src,
opName#"_e32 $dst, $src0", pattern
>, VOP <opName>;

def _e64 : VOP3 <
{1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
defm _e64 : VOP3_1_m <
op,
(outs drc:$dst),
(ins InputMods:$src0_modifiers, src:$src0, i32imm:$clamp, i32imm:$omod),
opName#"_e64 $dst, $src0_modifiers, $clamp, $omod", []
>, VOP <opName> {
let src1 = 0;
let src1_modifiers = 0;
let src2 = 0;
let src2_modifiers = 0;
}
opName#"_e64 $dst, $src0_modifiers, $clamp, $omod", [], opName>;
}

multiclass VOP1_32 <bits<8> op, string opName, list<dag> pattern>
Expand All @@ -341,17 +373,14 @@ multiclass VOP2_Helper <bits<6> op, RegisterClass vrc, RegisterClass arc,
opName#"_e32 $dst, $src0, $src1", pattern
>, VOP <opName>, VOP2_REV<revOp#"_e32", !eq(revOp, opName)>;

def _e64 : VOP3 <
{1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
defm _e64 : VOP3_2_m <
op,
(outs vrc:$dst),
(ins InputMods:$src0_modifiers, arc:$src0,
InputMods:$src1_modifiers, arc:$src1,
i32imm:$clamp, i32imm:$omod),
opName#"_e64 $dst, $src0_modifiers, $src1_modifiers, $clamp, $omod", []
>, VOP <opName>, VOP2_REV<revOp#"_e64", !eq(revOp, opName)> {
let src2 = 0;
let src2_modifiers = 0;
}
opName#"_e64 $dst, $src0_modifiers, $src1_modifiers, $clamp, $omod", [],
opName, revOp>;
}

multiclass VOP2_32 <bits<6> op, string opName, list<dag> pattern,
Expand Down

0 comments on commit 163d8ce

Please sign in to comment.