SparcInstrFormats.td revision 276479
1234353Sdim//===-- SparcInstrFormats.td - Sparc Instruction Formats ---*- tablegen -*-===// 2234353Sdim// 3193323Sed// The LLVM Compiler Infrastructure 4193323Sed// 5193323Sed// This file is distributed under the University of Illinois Open Source 6193323Sed// License. See LICENSE.TXT for details. 7234353Sdim// 8193323Sed//===----------------------------------------------------------------------===// 9193323Sed 10261991Sdimclass InstSP<dag outs, dag ins, string asmstr, list<dag> pattern> 11261991Sdim : Instruction { 12193323Sed field bits<32> Inst; 13193323Sed 14193323Sed let Namespace = "SP"; 15262613Sdim let Size = 4; 16193323Sed 17193323Sed bits<2> op; 18193323Sed let Inst{31-30} = op; // Top two bits are the 'op' field 19261991Sdim 20193323Sed dag OutOperandList = outs; 21193323Sed dag InOperandList = ins; 22193323Sed let AsmString = asmstr; 23193323Sed let Pattern = pattern; 24262613Sdim 25262613Sdim let DecoderNamespace = "Sparc"; 26262613Sdim field bits<32> SoftFail = 0; 27193323Sed} 28193323Sed 29193323Sed//===----------------------------------------------------------------------===// 30193323Sed// Format #2 instruction classes in the Sparc 31193323Sed//===----------------------------------------------------------------------===// 32193323Sed 33193323Sed// Format 2 instructions 34193323Sedclass F2<dag outs, dag ins, string asmstr, list<dag> pattern> 35193323Sed : InstSP<outs, ins, asmstr, pattern> { 36193323Sed bits<3> op2; 37193323Sed bits<22> imm22; 38193323Sed let op = 0; // op = 0 39193323Sed let Inst{24-22} = op2; 40193323Sed let Inst{21-0} = imm22; 41193323Sed} 42193323Sed 43193323Sed// Specific F2 classes: SparcV8 manual, page 44 44193323Sed// 45193323Sedclass F2_1<bits<3> op2Val, dag outs, dag ins, string asmstr, list<dag> pattern> 46193323Sed : F2<outs, ins, asmstr, pattern> { 47193323Sed bits<5> rd; 48193323Sed 49193323Sed let op2 = op2Val; 50193323Sed 51193323Sed let Inst{29-25} = rd; 52193323Sed} 53193323Sed 54276479Sdimclass F2_2<bits<3> op2Val, bit annul, dag outs, dag ins, string asmstr, 55193323Sed list<dag> pattern> : F2<outs, ins, asmstr, pattern> { 56193323Sed bits<4> cond; 57193323Sed let op2 = op2Val; 58193323Sed 59193323Sed let Inst{29} = annul; 60193323Sed let Inst{28-25} = cond; 61193323Sed} 62193323Sed 63276479Sdimclass F2_3<bits<3> op2Val, bit annul, bit pred, 64276479Sdim dag outs, dag ins, string asmstr, list<dag> pattern> 65276479Sdim : InstSP<outs, ins, asmstr, pattern> { 66276479Sdim bits<2> cc; 67262613Sdim bits<4> cond; 68262613Sdim bits<19> imm19; 69262613Sdim 70262613Sdim let op = 0; // op = 0 71262613Sdim 72262613Sdim let Inst{29} = annul; 73262613Sdim let Inst{28-25} = cond; 74262613Sdim let Inst{24-22} = op2Val; 75276479Sdim let Inst{21-20} = cc; 76262613Sdim let Inst{19} = pred; 77262613Sdim let Inst{18-0} = imm19; 78262613Sdim} 79262613Sdim 80276479Sdimclass F2_4<bits<3> cond, bit annul, bit pred, 81276479Sdim dag outs, dag ins, string asmstr, list<dag> pattern> 82276479Sdim : InstSP<outs, ins, asmstr, pattern> { 83276479Sdim bits<16> imm16; 84276479Sdim bits<5> rs1; 85276479Sdim 86276479Sdim let op = 0; // op = 0 87276479Sdim 88276479Sdim let Inst{29} = annul; 89276479Sdim let Inst{28} = 0; 90276479Sdim let Inst{27-25} = cond; 91276479Sdim let Inst{24-22} = 0b011; 92276479Sdim let Inst{21-20} = imm16{15-14}; 93276479Sdim let Inst{19} = pred; 94276479Sdim let Inst{18-14} = rs1; 95276479Sdim let Inst{13-0} = imm16{13-0}; 96276479Sdim} 97276479Sdim 98276479Sdim 99193323Sed//===----------------------------------------------------------------------===// 100193323Sed// Format #3 instruction classes in the Sparc 101193323Sed//===----------------------------------------------------------------------===// 102193323Sed 103193323Sedclass F3<dag outs, dag ins, string asmstr, list<dag> pattern> 104193323Sed : InstSP<outs, ins, asmstr, pattern> { 105193323Sed bits<5> rd; 106193323Sed bits<6> op3; 107193323Sed bits<5> rs1; 108193323Sed let op{1} = 1; // Op = 2 or 3 109193323Sed let Inst{29-25} = rd; 110193323Sed let Inst{24-19} = op3; 111193323Sed let Inst{18-14} = rs1; 112193323Sed} 113193323Sed 114193323Sed// Specific F3 classes: SparcV8 manual, page 44 115193323Sed// 116262613Sdimclass F3_1_asi<bits<2> opVal, bits<6> op3val, bits<8> asi, dag outs, dag ins, 117193323Sed string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> { 118193323Sed bits<5> rs2; 119193323Sed 120193323Sed let op = opVal; 121193323Sed let op3 = op3val; 122193323Sed 123193323Sed let Inst{13} = 0; // i field = 0 124193323Sed let Inst{12-5} = asi; // address space identifier 125193323Sed let Inst{4-0} = rs2; 126193323Sed} 127193323Sed 128262613Sdimclass F3_1<bits<2> opVal, bits<6> op3val, dag outs, dag ins, string asmstr, 129262613Sdim list<dag> pattern> : F3_1_asi<opVal, op3val, 0, outs, ins, 130262613Sdim asmstr, pattern>; 131262613Sdim 132261991Sdimclass F3_2<bits<2> opVal, bits<6> op3val, dag outs, dag ins, 133193323Sed string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> { 134193323Sed bits<13> simm13; 135193323Sed 136193323Sed let op = opVal; 137193323Sed let op3 = op3val; 138193323Sed 139193323Sed let Inst{13} = 1; // i field = 1 140193323Sed let Inst{12-0} = simm13; 141193323Sed} 142193323Sed 143193323Sed// floating-point 144193323Sedclass F3_3<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins, 145193323Sed string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> { 146193323Sed bits<5> rs2; 147193323Sed 148193323Sed let op = opVal; 149193323Sed let op3 = op3val; 150193323Sed 151193323Sed let Inst{13-5} = opfval; // fp opcode 152193323Sed let Inst{4-0} = rs2; 153193323Sed} 154193323Sed 155261991Sdim// floating-point unary operations. 156261991Sdimclass F3_3u<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins, 157261991Sdim string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> { 158261991Sdim bits<5> rs2; 159261991Sdim 160261991Sdim let op = opVal; 161261991Sdim let op3 = op3val; 162261991Sdim let rs1 = 0; 163261991Sdim 164261991Sdim let Inst{13-5} = opfval; // fp opcode 165261991Sdim let Inst{4-0} = rs2; 166261991Sdim} 167261991Sdim 168261991Sdim// floating-point compares. 169261991Sdimclass F3_3c<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins, 170261991Sdim string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> { 171261991Sdim bits<5> rs2; 172261991Sdim 173261991Sdim let op = opVal; 174261991Sdim let op3 = op3val; 175261991Sdim 176261991Sdim let Inst{13-5} = opfval; // fp opcode 177261991Sdim let Inst{4-0} = rs2; 178261991Sdim} 179261991Sdim 180249423Sdim// Shift by register rs2. 181249423Sdimclass F3_Sr<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins, 182249423Sdim string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> { 183249423Sdim bit x = xVal; // 1 for 64-bit shifts. 184249423Sdim bits<5> rs2; 185193323Sed 186249423Sdim let op = opVal; 187249423Sdim let op3 = op3val; 188249423Sdim 189249423Sdim let Inst{13} = 0; // i field = 0 190249423Sdim let Inst{12} = x; // extended registers. 191249423Sdim let Inst{4-0} = rs2; 192249423Sdim} 193249423Sdim 194249423Sdim// Shift by immediate. 195249423Sdimclass F3_Si<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins, 196249423Sdim string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> { 197249423Sdim bit x = xVal; // 1 for 64-bit shifts. 198249423Sdim bits<6> shcnt; // shcnt32 / shcnt64. 199249423Sdim 200249423Sdim let op = opVal; 201249423Sdim let op3 = op3val; 202249423Sdim 203249423Sdim let Inst{13} = 1; // i field = 1 204249423Sdim let Inst{12} = x; // extended registers. 205249423Sdim let Inst{5-0} = shcnt; 206249423Sdim} 207249423Sdim 208249423Sdim// Define rr and ri shift instructions with patterns. 209249423Sdimmulticlass F3_S<string OpcStr, bits<6> Op3Val, bit XVal, SDNode OpNode, 210249423Sdim ValueType VT, RegisterClass RC> { 211262613Sdim def rr : F3_Sr<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, IntRegs:$rs2), 212262613Sdim !strconcat(OpcStr, " $rs1, $rs2, $rd"), 213262613Sdim [(set VT:$rd, (OpNode VT:$rs1, i32:$rs2))]>; 214262613Sdim def ri : F3_Si<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, i32imm:$shcnt), 215262613Sdim !strconcat(OpcStr, " $rs1, $shcnt, $rd"), 216262613Sdim [(set VT:$rd, (OpNode VT:$rs1, (i32 imm:$shcnt)))]>; 217249423Sdim} 218261991Sdim 219261991Sdimclass F4<bits<6> op3, dag outs, dag ins, string asmstr, list<dag> pattern> 220261991Sdim : InstSP<outs, ins, asmstr, pattern> { 221261991Sdim bits<5> rd; 222261991Sdim 223261991Sdim let op = 2; 224261991Sdim let Inst{29-25} = rd; 225261991Sdim let Inst{24-19} = op3; 226261991Sdim} 227261991Sdim 228261991Sdim 229261991Sdimclass F4_1<bits<6> op3, dag outs, dag ins, 230261991Sdim string asmstr, list<dag> pattern> 231261991Sdim : F4<op3, outs, ins, asmstr, pattern> { 232261991Sdim 233276479Sdim bit intcc; 234276479Sdim bits<2> cc; 235261991Sdim bits<4> cond; 236261991Sdim bits<5> rs2; 237261991Sdim 238261991Sdim let Inst{4-0} = rs2; 239276479Sdim let Inst{12-11} = cc; 240261991Sdim let Inst{13} = 0; 241261991Sdim let Inst{17-14} = cond; 242276479Sdim let Inst{18} = intcc; 243261991Sdim 244261991Sdim} 245261991Sdim 246261991Sdimclass F4_2<bits<6> op3, dag outs, dag ins, 247261991Sdim string asmstr, list<dag> pattern> 248261991Sdim : F4<op3, outs, ins, asmstr, pattern> { 249276479Sdim bit intcc; 250276479Sdim bits<2> cc; 251261991Sdim bits<4> cond; 252261991Sdim bits<11> simm11; 253261991Sdim 254261991Sdim let Inst{10-0} = simm11; 255276479Sdim let Inst{12-11} = cc; 256261991Sdim let Inst{13} = 1; 257261991Sdim let Inst{17-14} = cond; 258276479Sdim let Inst{18} = intcc; 259261991Sdim} 260261991Sdim 261261991Sdimclass F4_3<bits<6> op3, bits<6> opf_low, dag outs, dag ins, 262261991Sdim string asmstr, list<dag> pattern> 263261991Sdim : F4<op3, outs, ins, asmstr, pattern> { 264261991Sdim bits<4> cond; 265276479Sdim bit intcc; 266276479Sdim bits<2> opf_cc; 267261991Sdim bits<5> rs2; 268261991Sdim 269261991Sdim let Inst{18} = 0; 270261991Sdim let Inst{17-14} = cond; 271276479Sdim let Inst{13} = intcc; 272276479Sdim let Inst{12-11} = opf_cc; 273261991Sdim let Inst{10-5} = opf_low; 274261991Sdim let Inst{4-0} = rs2; 275261991Sdim} 276276479Sdim 277276479Sdimclass F4_4r<bits<6> op3, bits<5> opf_low, bits<3> rcond, dag outs, dag ins, 278276479Sdim string asmstr, list<dag> pattern> 279276479Sdim : F4<op3, outs, ins, asmstr, pattern> { 280276479Sdim bits <5> rs1; 281276479Sdim bits <5> rs2; 282276479Sdim let Inst{18-14} = rs1; 283276479Sdim let Inst{13} = 0; // IsImm 284276479Sdim let Inst{12-10} = rcond; 285276479Sdim let Inst{9-5} = opf_low; 286276479Sdim let Inst{4-0} = rs2; 287276479Sdim} 288276479Sdim 289276479Sdim 290276479Sdimclass F4_4i<bits<6> op3, bits<3> rcond, dag outs, dag ins, 291276479Sdim string asmstr, list<dag> pattern> 292276479Sdim : F4<op3, outs, ins, asmstr, pattern> { 293276479Sdim bits<5> rs1; 294276479Sdim bits<10> simm10; 295276479Sdim let Inst{18-14} = rs1; 296276479Sdim let Inst{13} = 1; // IsImm 297276479Sdim let Inst{12-10} = rcond; 298276479Sdim let Inst{9-0} = simm10; 299276479Sdim} 300276479Sdim 301276479Sdim 302276479Sdimclass TRAPSP<bits<6> op3Val, bit isimm, dag outs, dag ins, string asmstr, 303276479Sdim list<dag> pattern>: F3<outs, ins, asmstr, pattern> { 304276479Sdim 305276479Sdim bits<4> cond; 306276479Sdim bits<2> cc; 307276479Sdim 308276479Sdim let op = 0b10; 309276479Sdim let rd{4} = 0; 310276479Sdim let rd{3-0} = cond; 311276479Sdim let op3 = op3Val; 312276479Sdim let Inst{13} = isimm; 313276479Sdim let Inst{12-11} = cc; 314276479Sdim 315276479Sdim} 316276479Sdim 317276479Sdimclass TRAPSPrr<bits<6> op3Val, dag outs, dag ins, string asmstr, 318276479Sdim list<dag> pattern>: TRAPSP<op3Val, 0, outs, ins, asmstr, pattern> { 319276479Sdim bits<5> rs2; 320276479Sdim 321276479Sdim let Inst{10-5} = 0; 322276479Sdim let Inst{4-0} = rs2; 323276479Sdim} 324276479Sdimclass TRAPSPri<bits<6> op3Val, dag outs, dag ins, string asmstr, 325276479Sdim list<dag> pattern>: TRAPSP<op3Val, 1, outs, ins, asmstr, pattern> { 326276479Sdim bits<8> imm; 327276479Sdim 328276479Sdim let Inst{10-8} = 0; 329276479Sdim let Inst{7-0} = imm; 330276479Sdim} 331