10b57cec5SDimitry Andric 20b57cec5SDimitry Andricclass R600Reg <string name, bits<16> encoding> : Register<name> { 30b57cec5SDimitry Andric let Namespace = "AMDGPU"; 40b57cec5SDimitry Andric let HWEncoding = encoding; 50b57cec5SDimitry Andric} 60b57cec5SDimitry Andric 70b57cec5SDimitry Andricclass R600RegWithChan <string name, bits<9> sel, string chan> : 80b57cec5SDimitry Andric Register <name> { 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric field bits<2> chan_encoding = !if(!eq(chan, "X"), 0, 110b57cec5SDimitry Andric !if(!eq(chan, "Y"), 1, 120b57cec5SDimitry Andric !if(!eq(chan, "Z"), 2, 130b57cec5SDimitry Andric !if(!eq(chan, "W"), 3, 0)))); 140b57cec5SDimitry Andric let HWEncoding{8-0} = sel; 150b57cec5SDimitry Andric let HWEncoding{10-9} = chan_encoding; 160b57cec5SDimitry Andric let Namespace = "AMDGPU"; 170b57cec5SDimitry Andric} 180b57cec5SDimitry Andric 190b57cec5SDimitry Andricclass R600Reg_128<string n, list<Register> subregs, bits<16> encoding> : 200b57cec5SDimitry Andric RegisterWithSubRegs<n, subregs> { 210b57cec5SDimitry Andric field bits<2> chan_encoding = 0; 220b57cec5SDimitry Andric let Namespace = "AMDGPU"; 230b57cec5SDimitry Andric let SubRegIndices = [sub0, sub1, sub2, sub3]; 240b57cec5SDimitry Andric let HWEncoding{8-0} = encoding{8-0}; 250b57cec5SDimitry Andric let HWEncoding{10-9} = chan_encoding; 260b57cec5SDimitry Andric} 270b57cec5SDimitry Andric 280b57cec5SDimitry Andricclass R600Reg_64<string n, list<Register> subregs, bits<16> encoding> : 290b57cec5SDimitry Andric RegisterWithSubRegs<n, subregs> { 300b57cec5SDimitry Andric field bits<2> chan_encoding = 0; 310b57cec5SDimitry Andric let Namespace = "AMDGPU"; 320b57cec5SDimitry Andric let SubRegIndices = [sub0, sub1]; 330b57cec5SDimitry Andric let HWEncoding = encoding; 340b57cec5SDimitry Andric let HWEncoding{8-0} = encoding{8-0}; 350b57cec5SDimitry Andric let HWEncoding{10-9} = chan_encoding; 360b57cec5SDimitry Andric} 370b57cec5SDimitry Andric 380b57cec5SDimitry Andricclass R600Reg_64Vertical<int lo, int hi, string chan> : R600Reg_64 < 390b57cec5SDimitry Andric "V"#lo#hi#"_"#chan, 400b57cec5SDimitry Andric [!cast<Register>("T"#lo#"_"#chan), !cast<Register>("T"#hi#"_"#chan)], 410b57cec5SDimitry Andric lo 420b57cec5SDimitry Andric>; 430b57cec5SDimitry Andric 440b57cec5SDimitry Andricforeach Index = 0-127 in { 450b57cec5SDimitry Andric foreach Chan = [ "X", "Y", "Z", "W" ] in { 460b57cec5SDimitry Andric // 32-bit Temporary Registers 470b57cec5SDimitry Andric def T#Index#_#Chan : R600RegWithChan <"T"#Index#"."#Chan, Index, Chan>; 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric // Indirect addressing offset registers 500b57cec5SDimitry Andric def Addr#Index#_#Chan : R600RegWithChan <"T("#Index#" + AR.x)."#Chan, 510b57cec5SDimitry Andric Index, Chan>; 520b57cec5SDimitry Andric } 530b57cec5SDimitry Andric // 128-bit Temporary Registers 540b57cec5SDimitry Andric def T#Index#_XYZW : R600Reg_128 <"T"#Index#"", 550b57cec5SDimitry Andric [!cast<Register>("T"#Index#"_X"), 560b57cec5SDimitry Andric !cast<Register>("T"#Index#"_Y"), 570b57cec5SDimitry Andric !cast<Register>("T"#Index#"_Z"), 580b57cec5SDimitry Andric !cast<Register>("T"#Index#"_W")], 590b57cec5SDimitry Andric Index>; 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric def T#Index#_XY : R600Reg_64 <"T"#Index#"", 620b57cec5SDimitry Andric [!cast<Register>("T"#Index#"_X"), 630b57cec5SDimitry Andric !cast<Register>("T"#Index#"_Y")], 640b57cec5SDimitry Andric Index>; 650b57cec5SDimitry Andric} 660b57cec5SDimitry Andric 670b57cec5SDimitry Andricforeach Chan = [ "X", "Y", "Z", "W"] in { 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric let chan_encoding = !if(!eq(Chan, "X"), 0, 700b57cec5SDimitry Andric !if(!eq(Chan, "Y"), 1, 710b57cec5SDimitry Andric !if(!eq(Chan, "Z"), 2, 720b57cec5SDimitry Andric !if(!eq(Chan, "W"), 3, 0)))) in { 730b57cec5SDimitry Andric def V0123_#Chan : R600Reg_128 <"V0123_"#Chan, 740b57cec5SDimitry Andric [!cast<Register>("T0_"#Chan), 750b57cec5SDimitry Andric !cast<Register>("T1_"#Chan), 760b57cec5SDimitry Andric !cast<Register>("T2_"#Chan), 770b57cec5SDimitry Andric !cast<Register>("T3_"#Chan)], 780b57cec5SDimitry Andric 0>; 790b57cec5SDimitry Andric def V01_#Chan : R600Reg_64Vertical<0, 1, Chan>; 800b57cec5SDimitry Andric def V23_#Chan : R600Reg_64Vertical<2, 3, Chan>; 810b57cec5SDimitry Andric } 820b57cec5SDimitry Andric} 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric// KCACHE_BANK0 860b57cec5SDimitry Andricforeach Index = 159-128 in { 870b57cec5SDimitry Andric foreach Chan = [ "X", "Y", "Z", "W" ] in { 880b57cec5SDimitry Andric // 32-bit Temporary Registers 890b57cec5SDimitry Andric def KC0_#Index#_#Chan : R600RegWithChan <"KC0["#!add(Index,-128)#"]."#Chan, Index, Chan>; 900b57cec5SDimitry Andric } 910b57cec5SDimitry Andric // 128-bit Temporary Registers 920b57cec5SDimitry Andric def KC0_#Index#_XYZW : R600Reg_128 <"KC0["#!add(Index, -128)#"].XYZW", 930b57cec5SDimitry Andric [!cast<Register>("KC0_"#Index#"_X"), 940b57cec5SDimitry Andric !cast<Register>("KC0_"#Index#"_Y"), 950b57cec5SDimitry Andric !cast<Register>("KC0_"#Index#"_Z"), 960b57cec5SDimitry Andric !cast<Register>("KC0_"#Index#"_W")], 970b57cec5SDimitry Andric Index>; 980b57cec5SDimitry Andric} 990b57cec5SDimitry Andric 1000b57cec5SDimitry Andric// KCACHE_BANK1 1010b57cec5SDimitry Andricforeach Index = 191-160 in { 1020b57cec5SDimitry Andric foreach Chan = [ "X", "Y", "Z", "W" ] in { 1030b57cec5SDimitry Andric // 32-bit Temporary Registers 1040b57cec5SDimitry Andric def KC1_#Index#_#Chan : R600RegWithChan <"KC1["#!add(Index,-160)#"]."#Chan, Index, Chan>; 1050b57cec5SDimitry Andric } 1060b57cec5SDimitry Andric // 128-bit Temporary Registers 1070b57cec5SDimitry Andric def KC1_#Index#_XYZW : R600Reg_128 <"KC1["#!add(Index, -160)#"].XYZW", 1080b57cec5SDimitry Andric [!cast<Register>("KC1_"#Index#"_X"), 1090b57cec5SDimitry Andric !cast<Register>("KC1_"#Index#"_Y"), 1100b57cec5SDimitry Andric !cast<Register>("KC1_"#Index#"_Z"), 1110b57cec5SDimitry Andric !cast<Register>("KC1_"#Index#"_W")], 1120b57cec5SDimitry Andric Index>; 1130b57cec5SDimitry Andric} 1140b57cec5SDimitry Andric 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andric// Array Base Register holding input in FS 1170b57cec5SDimitry Andricforeach Index = 448-480 in { 1180b57cec5SDimitry Andric def ArrayBase#Index : R600Reg<"ARRAY_BASE", Index>; 1190b57cec5SDimitry Andric} 1200b57cec5SDimitry Andric 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andric// Special Registers 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andricdef OQA : R600Reg<"OQA", 219>; 1250b57cec5SDimitry Andricdef OQB : R600Reg<"OQB", 220>; 1260b57cec5SDimitry Andricdef OQAP : R600Reg<"OQAP", 221>; 1270b57cec5SDimitry Andricdef OQBP : R600Reg<"OQAP", 222>; 1280b57cec5SDimitry Andricdef LDS_DIRECT_A : R600Reg<"LDS_DIRECT_A", 223>; 1290b57cec5SDimitry Andricdef LDS_DIRECT_B : R600Reg<"LDS_DIRECT_B", 224>; 1300b57cec5SDimitry Andricdef ZERO : R600Reg<"0.0", 248>; 1310b57cec5SDimitry Andricdef ONE : R600Reg<"1.0", 249>; 1320b57cec5SDimitry Andricdef NEG_ONE : R600Reg<"-1.0", 249>; 1330b57cec5SDimitry Andricdef ONE_INT : R600Reg<"1", 250>; 1340b57cec5SDimitry Andricdef HALF : R600Reg<"0.5", 252>; 1350b57cec5SDimitry Andricdef NEG_HALF : R600Reg<"-0.5", 252>; 1360b57cec5SDimitry Andricdef ALU_LITERAL_X : R600RegWithChan<"literal.x", 253, "X">; 1370b57cec5SDimitry Andricdef ALU_LITERAL_Y : R600RegWithChan<"literal.y", 253, "Y">; 1380b57cec5SDimitry Andricdef ALU_LITERAL_Z : R600RegWithChan<"literal.z", 253, "Z">; 1390b57cec5SDimitry Andricdef ALU_LITERAL_W : R600RegWithChan<"literal.w", 253, "W">; 1400b57cec5SDimitry Andricdef PV_X : R600RegWithChan<"PV.X", 254, "X">; 1410b57cec5SDimitry Andricdef PV_Y : R600RegWithChan<"PV.Y", 254, "Y">; 1420b57cec5SDimitry Andricdef PV_Z : R600RegWithChan<"PV.Z", 254, "Z">; 1430b57cec5SDimitry Andricdef PV_W : R600RegWithChan<"PV.W", 254, "W">; 1440b57cec5SDimitry Andricdef PS: R600Reg<"PS", 255>; 1450b57cec5SDimitry Andricdef PREDICATE_BIT : R600Reg<"PredicateBit", 0>; 1460b57cec5SDimitry Andricdef PRED_SEL_OFF: R600Reg<"Pred_sel_off", 0>; 1470b57cec5SDimitry Andricdef PRED_SEL_ZERO : R600Reg<"Pred_sel_zero", 2>; 1480b57cec5SDimitry Andricdef PRED_SEL_ONE : R600Reg<"Pred_sel_one", 3>; 1490b57cec5SDimitry Andricdef AR_X : R600Reg<"AR.x", 0>; 1500b57cec5SDimitry Andricdef INDIRECT_BASE_ADDR : R600Reg <"INDIRECT_BASE_ADDR", 0>; 1510b57cec5SDimitry Andric 1520b57cec5SDimitry Andricdef R600_ArrayBase : RegisterClass <"AMDGPU", [f32, i32], 32, 153*5ffd83dbSDimitry Andric (add (sequence "ArrayBase%u", 448, 480))> { 154*5ffd83dbSDimitry Andric let Weight = 0; 155*5ffd83dbSDimitry Andric} 1560b57cec5SDimitry Andric// special registers for ALU src operands 1570b57cec5SDimitry Andric// const buffer reference, SRCx_SEL contains index 1580b57cec5SDimitry Andricdef ALU_CONST : R600Reg<"CBuf", 0>; 1590b57cec5SDimitry Andric// interpolation param reference, SRCx_SEL contains index 1600b57cec5SDimitry Andricdef ALU_PARAM : R600Reg<"Param", 0>; 1610b57cec5SDimitry Andric 162*5ffd83dbSDimitry Andriclet Weight = 0 in { 1630b57cec5SDimitry Andriclet isAllocatable = 0 in { 1640b57cec5SDimitry Andric 1650b57cec5SDimitry Andricdef R600_Addr : RegisterClass <"AMDGPU", [i32], 32, (add (sequence "Addr%u_X", 0, 127))>; 1660b57cec5SDimitry Andric 1670b57cec5SDimitry Andric// We only use Addr_[YZW] for vertical vectors. 1680b57cec5SDimitry Andric// FIXME if we add more vertical vector registers we will need to ad more 1690b57cec5SDimitry Andric// registers to these classes. 1700b57cec5SDimitry Andricdef R600_Addr_Y : RegisterClass <"AMDGPU", [i32], 32, (add Addr0_Y)>; 1710b57cec5SDimitry Andricdef R600_Addr_Z : RegisterClass <"AMDGPU", [i32], 32, (add Addr0_Z)>; 1720b57cec5SDimitry Andricdef R600_Addr_W : RegisterClass <"AMDGPU", [i32], 32, (add Addr0_W)>; 1730b57cec5SDimitry Andric 1740b57cec5SDimitry Andricdef R600_LDS_SRC_REG : RegisterClass<"AMDGPU", [i32], 32, 1750b57cec5SDimitry Andric (add OQA, OQB, OQAP, OQBP, LDS_DIRECT_A, LDS_DIRECT_B)>; 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andricdef R600_KC0_X : RegisterClass <"AMDGPU", [f32, i32], 32, 1780b57cec5SDimitry Andric (add (sequence "KC0_%u_X", 128, 159))>; 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andricdef R600_KC0_Y : RegisterClass <"AMDGPU", [f32, i32], 32, 1810b57cec5SDimitry Andric (add (sequence "KC0_%u_Y", 128, 159))>; 1820b57cec5SDimitry Andric 1830b57cec5SDimitry Andricdef R600_KC0_Z : RegisterClass <"AMDGPU", [f32, i32], 32, 1840b57cec5SDimitry Andric (add (sequence "KC0_%u_Z", 128, 159))>; 1850b57cec5SDimitry Andric 1860b57cec5SDimitry Andricdef R600_KC0_W : RegisterClass <"AMDGPU", [f32, i32], 32, 1870b57cec5SDimitry Andric (add (sequence "KC0_%u_W", 128, 159))>; 1880b57cec5SDimitry Andric 1890b57cec5SDimitry Andricdef R600_KC0 : RegisterClass <"AMDGPU", [f32, i32], 32, 1900b57cec5SDimitry Andric (interleave R600_KC0_X, R600_KC0_Y, 1910b57cec5SDimitry Andric R600_KC0_Z, R600_KC0_W)>; 1920b57cec5SDimitry Andric 1930b57cec5SDimitry Andricdef R600_KC1_X : RegisterClass <"AMDGPU", [f32, i32], 32, 1940b57cec5SDimitry Andric (add (sequence "KC1_%u_X", 160, 191))>; 1950b57cec5SDimitry Andric 1960b57cec5SDimitry Andricdef R600_KC1_Y : RegisterClass <"AMDGPU", [f32, i32], 32, 1970b57cec5SDimitry Andric (add (sequence "KC1_%u_Y", 160, 191))>; 1980b57cec5SDimitry Andric 1990b57cec5SDimitry Andricdef R600_KC1_Z : RegisterClass <"AMDGPU", [f32, i32], 32, 2000b57cec5SDimitry Andric (add (sequence "KC1_%u_Z", 160, 191))>; 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andricdef R600_KC1_W : RegisterClass <"AMDGPU", [f32, i32], 32, 2030b57cec5SDimitry Andric (add (sequence "KC1_%u_W", 160, 191))>; 2040b57cec5SDimitry Andric 2050b57cec5SDimitry Andricdef R600_KC1 : RegisterClass <"AMDGPU", [f32, i32], 32, 2060b57cec5SDimitry Andric (interleave R600_KC1_X, R600_KC1_Y, 2070b57cec5SDimitry Andric R600_KC1_Z, R600_KC1_W)>; 2080b57cec5SDimitry Andric 2090b57cec5SDimitry Andric} // End isAllocatable = 0 2100b57cec5SDimitry Andric 2110b57cec5SDimitry Andricdef R600_TReg32_X : RegisterClass <"AMDGPU", [f32, i32], 32, 2120b57cec5SDimitry Andric (add (sequence "T%u_X", 0, 127), AR_X)>; 2130b57cec5SDimitry Andric 2140b57cec5SDimitry Andricdef R600_TReg32_Y : RegisterClass <"AMDGPU", [f32, i32], 32, 2150b57cec5SDimitry Andric (add (sequence "T%u_Y", 0, 127))>; 2160b57cec5SDimitry Andric 2170b57cec5SDimitry Andricdef R600_TReg32_Z : RegisterClass <"AMDGPU", [f32, i32], 32, 2180b57cec5SDimitry Andric (add (sequence "T%u_Z", 0, 127))>; 2190b57cec5SDimitry Andric 2200b57cec5SDimitry Andricdef R600_TReg32_W : RegisterClass <"AMDGPU", [f32, i32], 32, 2210b57cec5SDimitry Andric (add (sequence "T%u_W", 0, 127))>; 2220b57cec5SDimitry Andric 2230b57cec5SDimitry Andricdef R600_TReg32 : RegisterClass <"AMDGPU", [f32, i32], 32, 2240b57cec5SDimitry Andric (interleave R600_TReg32_X, R600_TReg32_Y, 2250b57cec5SDimitry Andric R600_TReg32_Z, R600_TReg32_W)>; 2260b57cec5SDimitry Andric 2270b57cec5SDimitry Andricdef R600_Reg32 : RegisterClass <"AMDGPU", [f32, i32], 32, (add 2280b57cec5SDimitry Andric R600_TReg32, 2290b57cec5SDimitry Andric R600_ArrayBase, 2300b57cec5SDimitry Andric R600_Addr, 2310b57cec5SDimitry Andric R600_KC0, R600_KC1, 2320b57cec5SDimitry Andric ZERO, HALF, ONE, ONE_INT, PV_X, ALU_LITERAL_X, NEG_ONE, NEG_HALF, 2330b57cec5SDimitry Andric ALU_CONST, ALU_PARAM, OQAP, INDIRECT_BASE_ADDR 2340b57cec5SDimitry Andric )>; 2350b57cec5SDimitry Andric 2360b57cec5SDimitry Andricdef R600_Predicate : RegisterClass <"AMDGPU", [i32], 32, (add 2370b57cec5SDimitry Andric PRED_SEL_OFF, PRED_SEL_ZERO, PRED_SEL_ONE)>; 2380b57cec5SDimitry Andric 2390b57cec5SDimitry Andricdef R600_Predicate_Bit: RegisterClass <"AMDGPU", [i32], 32, (add 2400b57cec5SDimitry Andric PREDICATE_BIT)>; 2410b57cec5SDimitry Andric 2420b57cec5SDimitry Andricdef R600_Reg128 : RegisterClass<"AMDGPU", [v4f32, v4i32], 128, 2430b57cec5SDimitry Andric (add (sequence "T%u_XYZW", 0, 127))> { 2440b57cec5SDimitry Andric let CopyCost = -1; 2450b57cec5SDimitry Andric} 2460b57cec5SDimitry Andric 2470b57cec5SDimitry Andricdef R600_Reg128Vertical : RegisterClass<"AMDGPU", [v4f32, v4i32], 128, 2480b57cec5SDimitry Andric (add V0123_W, V0123_Z, V0123_Y, V0123_X) 2490b57cec5SDimitry Andric>; 2500b57cec5SDimitry Andric 2510b57cec5SDimitry Andricdef R600_Reg64 : RegisterClass<"AMDGPU", [v2f32, v2i32, i64, f64], 64, 2520b57cec5SDimitry Andric (add (sequence "T%u_XY", 0, 63))>; 2530b57cec5SDimitry Andric 2540b57cec5SDimitry Andricdef R600_Reg64Vertical : RegisterClass<"AMDGPU", [v2f32, v2i32], 64, 2550b57cec5SDimitry Andric (add V01_X, V01_Y, V01_Z, V01_W, 2560b57cec5SDimitry Andric V23_X, V23_Y, V23_Z, V23_W)>; 257*5ffd83dbSDimitry Andric} // End let Weight = 0 258