Fixed spelling, removed trailing whitespace.
[oota-llvm.git] / lib / Target / CellSPU / SPU64InstrInfo.td
1 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2 // 64-bit comparisons:
3 //
4 // 1. The instruction sequences for vector vice scalar differ by a
5 //    constant.
6 //
7 // 2. There are no "immediate" forms, since loading 64-bit constants
8 //    could be a constant pool load.
9 //
10 // 3. i64 setcc results are i32, which are subsequently converted to a FSM
11 //    mask when used in a select pattern.
12 //
13 // 4. v2i64 setcc results are v4i32, which can be converted to a FSM mask
14 //    (TODO)
15 //
16 // M00$E Kan be Pretty N@sTi!!!!! (appologies to Monty!)
17 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
18
19 // selb instruction definition for i64. Note that the selection mask is
20 // a vector, produced by various forms of FSM:
21 def SELBr64_cond:
22    SELBInst<(outs R64C:$rT), (ins R64C:$rA, R64C:$rB, VECREG:$rC),
23             [/* no pattern */]>;
24
25 class CodeFrag<dag frag> {
26   dag Fragment = frag;
27 }
28
29 class I64SELECTNegCond<PatFrag cond, CodeFrag cmpare>:
30   Pat<(select (i32 (cond R64C:$rA, R64C:$rB)), R64C:$rTrue, R64C:$rFalse),
31       (SELBr64_cond R64C:$rTrue, R64C:$rFalse, (FSMr32 cmpare.Fragment))>;
32
33 class I64SETCCNegCond<PatFrag cond, CodeFrag cmpare>:
34   Pat<(cond R64C:$rA, R64C:$rB),
35       (XORIr32 cmpare.Fragment, -1)>;
36
37 // The i64 seteq fragment that does the scalar->vector conversion and
38 // comparison:
39 def CEQr64compare:
40     CodeFrag<(CGTIv4i32 (GBv4i32 (CEQv4i32 (ORv2i64_i64 R64C:$rA),
41                                            (ORv2i64_i64 R64C:$rB))),
42                         0x0000000c)>;
43
44
45 // The i64 seteq fragment that does the vector comparison
46 def CEQv2i64compare:
47     CodeFrag<(CGTIv4i32 (GBv4i32 (CEQv4i32 VECREG:$rA, VECREG:$rB)),
48                         0x0000000f)>;
49
50 // i64 seteq (equality): the setcc result is i32, which is converted to a
51 // vector FSM mask when used in a select pattern.
52 //
53 // v2i64 seteq (equality): the setcc result is v4i32
54 multiclass CompareEqual64 {
55   // Plain old comparison, converts back to i32 scalar
56   def r64: CodeFrag<(ORi32_v4i32 CEQr64compare.Fragment)>;
57   def v2i64: CodeFrag<(ORi32_v4i32 CEQv2i64compare.Fragment)>;
58
59   // SELB mask from FSM:
60   def r64mask: CodeFrag<(ORi32_v4i32 (FSMv4i32 CEQr64compare.Fragment))>;
61   def v2i64mask: CodeFrag<(ORi32_v4i32 (FSMv4i32 CEQv2i64compare.Fragment))>;
62 }
63
64 defm I64EQ: CompareEqual64;
65
66 def : Pat<(seteq R64C:$rA, R64C:$rB), I64EQr64.Fragment>;
67
68 def : Pat<(seteq (v2i64 VECREG:$rA), (v2i64 VECREG:$rB)),
69           I64EQv2i64.Fragment>;
70
71 def I64Select:
72     Pat<(select R32C:$rC, R64C:$rB, R64C:$rA),
73         (SELBr64_cond R64C:$rA, R64C:$rB, (FSMr32 R32C:$rC))>;
74
75 def : I64SETCCNegCond<setne, I64EQr64>;
76
77 def : I64SELECTNegCond<setne, I64EQr64>;