1 //===- AMDGPUGenRegisterBankInfo.def
-----------------------------*- C
++ -*-==//
3 // Part of the LLVM Project
, under the Apache License v2.0 with LLVM Exceptions.
4 // See https
://llvm.org
/LICENSE.txt for license information.
5 // SPDX
-License
-Identifier
: Apache
-2.0 WITH LLVM
-exception
7 //===----------------------------------------------------------------------===//
9 /// This file defines all the static objects used by AMDGPURegisterBankInfo.
10 /// \todo This should be generated by TableGen.
11 //===----------------------------------------------------------------------===//
16 enum PartialMappingIdx
{
36 const RegisterBankInfo
::PartialMapping PartMappings
[] {
37 // StartIdx
, Length
, RegBank
41 {0, 1, SGPRRegBank
}, // SGPR begin
45 {0, 128, SGPRRegBank
},
46 {0, 256, SGPRRegBank
},
47 {0, 512, SGPRRegBank
},
49 {0, 1, VGPRRegBank
}, // VGPR begin
53 {0, 128, VGPRRegBank
},
54 {0, 256, VGPRRegBank
},
55 {0, 512, VGPRRegBank
},
60 const RegisterBankInfo
::ValueMapping ValMappings
[] {
62 {&PartMappings
[0], 1},
65 {&PartMappings
[1], 1},
68 {&PartMappings
[2], 1},
69 {nullptr
, 0}, // Illegal power of
2 sizes
72 {&PartMappings
[3], 1},
73 {&PartMappings
[4], 1},
74 {&PartMappings
[5], 1},
75 {&PartMappings
[6], 1},
76 {&PartMappings
[7], 1},
77 {&PartMappings
[8], 1},
80 {&PartMappings
[9], 1},
84 {&PartMappings
[10], 1},
85 {&PartMappings
[11], 1},
86 {&PartMappings
[12], 1},
87 {&PartMappings
[13], 1},
88 {&PartMappings
[14], 1},
89 {&PartMappings
[15], 1},
90 {&PartMappings
[16], 1},
91 {&PartMappings
[17], 1}
94 const RegisterBankInfo
::PartialMapping SGPROnly64BreakDown
[] {
95 /*32-bit op
*/ {0, 32, SGPRRegBank
},
96 /*2x32
-bit op
*/ {0, 32, SGPRRegBank
},
97 {32, 32, SGPRRegBank
},
98 /*<2x32
-bit
> op
*/ {0, 64, SGPRRegBank
},
100 /*32-bit op
*/ {0, 32, VGPRRegBank
},
101 /*2x32
-bit op
*/ {0, 32, VGPRRegBank
},
102 {32, 32, VGPRRegBank
},
106 // For some instructions which can operate
64-bit only for the scalar version.
107 const RegisterBankInfo
::ValueMapping ValMappingsSGPR64OnlyVGPR32
[] {
108 /*32-bit sgpr
*/ {&SGPROnly64BreakDown
[0], 1},
109 /*2 x
32-bit sgpr
*/ {&SGPROnly64BreakDown
[1], 2},
110 /*64-bit sgpr
*/ {&SGPROnly64BreakDown
[3], 1},
112 /*32-bit vgpr
*/ {&SGPROnly64BreakDown
[4], 1},
113 /*2 x
32-bit vgpr
*/ {&SGPROnly64BreakDown
[5], 2}
116 enum ValueMappingIdx
{
122 const RegisterBankInfo
::ValueMapping
*getValueMapping(unsigned BankID
,
127 if (BankID
== AMDGPU
::SCCRegBankID
)
128 return
&ValMappings
[0];
129 if (BankID
== AMDGPU
::VCCRegBankID
)
130 return
&ValMappings
[1];
132 // 1-bit values not from a compare etc.
133 Idx
= BankID
== AMDGPU
::SGPRRegBankID ? PM_SGPR1
: PM_VGPR1
;
136 assert(BankID
!= AMDGPU
::VCCRegBankID
);
137 Idx
= BankID
== AMDGPU
::SGPRRegBankID ? PM_SGPR96
: PM_VGPR96
;
140 assert(BankID
!= AMDGPU
::VCCRegBankID
);
141 Idx
= BankID
== AMDGPU
::VGPRRegBankID ? VGPRStartIdx
: SGPRStartIdx
;
142 Idx
+= Log2_32_Ceil(Size
);
146 assert(Log2_32_Ceil(Size
) == Log2_32_Ceil(ValMappings
[Idx
].BreakDown
->Length
));
147 assert(BankID
== ValMappings
[Idx
].BreakDown
->RegBank
->getID());
149 return
&ValMappings
[Idx
];
152 const RegisterBankInfo
::ValueMapping
*getValueMappingSGPR64Only(unsigned BankID
,
155 return
getValueMapping(BankID
, Size
);
157 if (BankID
== AMDGPU
::VGPRRegBankID
)
158 return
&ValMappingsSGPR64OnlyVGPR32
[4];
160 assert(BankID
== AMDGPU
::SGPRRegBankID
);
161 return
&ValMappingsSGPR64OnlyVGPR32
[2];
164 } // End AMDGPU namespace.
165 } // End llvm namespace.