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
{
45 const RegisterBankInfo
::PartialMapping PartMappings
[] {
46 // StartIdx
, Length
, RegBank
49 {0, 1, SGPRRegBank
}, // SGPR begin
53 {0, 128, SGPRRegBank
},
54 {0, 256, SGPRRegBank
},
55 {0, 512, SGPRRegBank
},
56 {0, 1024, SGPRRegBank
},
58 {0, 1, VGPRRegBank
}, // VGPR begin
62 {0, 128, VGPRRegBank
},
63 {0, 256, VGPRRegBank
},
64 {0, 512, VGPRRegBank
},
65 {0, 1024, VGPRRegBank
},
70 {0, 32, AGPRRegBank
}, // AGPR begin
72 {0, 128, AGPRRegBank
},
73 {0, 256, AGPRRegBank
},
74 {0, 512, AGPRRegBank
},
75 {0, 1024, AGPRRegBank
}
78 const RegisterBankInfo
::ValueMapping ValMappings
[] {
80 {&PartMappings
[0], 1},
83 {&PartMappings
[1], 1}, // 1
84 {nullptr
, 0}, // Illegal power of
2 sizes
87 {&PartMappings
[2], 1}, // 16
88 {&PartMappings
[3], 1}, // 32
89 {&PartMappings
[4], 1}, // 64
90 {&PartMappings
[5], 1}, // 128
91 {&PartMappings
[6], 1}, // 256
92 {&PartMappings
[7], 1}, // 512
93 {&PartMappings
[8], 1}, // 1024
96 {&PartMappings
[9], 1}, // 1
100 {&PartMappings
[10], 1}, // 16
101 {&PartMappings
[11], 1}, // 32
102 {&PartMappings
[12], 1}, // 64
103 {&PartMappings
[13], 1}, // 128
104 {&PartMappings
[14], 1}, // 256
105 {&PartMappings
[15], 1}, // 512
106 {&PartMappings
[16], 1}, // 1024
107 {&PartMappings
[17], 1},
108 {&PartMappings
[18], 1},
109 {&PartMappings
[19], 1},
117 {&PartMappings
[20], 1}, // 32
118 {&PartMappings
[21], 1}, // 64
119 {&PartMappings
[22], 1}, // 128
120 {&PartMappings
[23], 1}, // 256
121 {&PartMappings
[24], 1}, // 512
122 {&PartMappings
[25], 1} // 1024
125 const RegisterBankInfo
::PartialMapping SGPROnly64BreakDown
[] {
126 {0, 32, SGPRRegBank
}, // 32-bit op
127 {0, 32, SGPRRegBank
}, // 2x32
-bit op
128 {32, 32, SGPRRegBank
},
129 {0, 64, SGPRRegBank
}, // <2x32
-bit
> op
131 {0, 32, VGPRRegBank
}, // 32-bit op
132 {0, 32, VGPRRegBank
}, // 2x32
-bit op
133 {32, 32, VGPRRegBank
},
137 // For some instructions which can operate
64-bit only for the scalar
138 // version. Otherwise
, these need to be split into
2 32-bit operations.
139 const RegisterBankInfo
::ValueMapping ValMappingsSGPR64OnlyVGPR32
[] {
140 /*32-bit sgpr
*/ {&SGPROnly64BreakDown
[0], 1},
141 /*2 x
32-bit sgpr
*/ {&SGPROnly64BreakDown
[1], 2},
142 /*64-bit sgpr
*/ {&SGPROnly64BreakDown
[3], 1},
144 /*32-bit vgpr
*/ {&SGPROnly64BreakDown
[4], 1},
145 /*2 x
32-bit vgpr
*/ {&SGPROnly64BreakDown
[5], 2}
148 enum ValueMappingIdx
{
154 const RegisterBankInfo
::ValueMapping
*getValueMapping(unsigned BankID
,
159 if (BankID
== AMDGPU
::VCCRegBankID
)
160 return
&ValMappings
[0];
162 Idx
= BankID
== AMDGPU
::SGPRRegBankID ? PM_SGPR1
: PM_VGPR1
;
166 case AMDGPU
::VGPRRegBankID
:
169 case AMDGPU
::SGPRRegBankID
:
172 case AMDGPU
::AGPRRegBankID
:
175 default
: llvm_unreachable("Invalid register bank");
180 case AMDGPU
::VGPRRegBankID
:
183 case AMDGPU
::SGPRRegBankID
:
186 case AMDGPU
::AGPRRegBankID
:
189 default
: llvm_unreachable("Invalid register bank");
191 Idx
+= Log2_32_Ceil(Size
);
195 assert(Log2_32_Ceil(Size
) == Log2_32_Ceil(ValMappings
[Idx
].BreakDown
->Length
));
196 assert(BankID
== ValMappings
[Idx
].BreakDown
->RegBank
->getID());
198 return
&ValMappings
[Idx
];
201 const RegisterBankInfo
::ValueMapping
*getValueMappingSGPR64Only(unsigned BankID
,
204 return
getValueMapping(BankID
, Size
);
206 if (BankID
== AMDGPU
::VGPRRegBankID
)
207 return
&ValMappingsSGPR64OnlyVGPR32
[4];
209 assert(BankID
== AMDGPU
::SGPRRegBankID
);
210 return
&ValMappingsSGPR64OnlyVGPR32
[2];
213 /// Split any
64-bit value into
2 32-bit pieces. Unlike
214 /// getValueMappingSGPR64Only
, this splits both VGPRs and SGPRs.
215 const RegisterBankInfo
::ValueMapping
*getValueMappingSplit64(unsigned BankID
,
218 if (BankID
== AMDGPU
::VGPRRegBankID
)
219 return
&ValMappingsSGPR64OnlyVGPR32
[4];
221 assert(BankID
== AMDGPU
::SGPRRegBankID
);
222 return
&ValMappingsSGPR64OnlyVGPR32
[1];
226 } // End AMDGPU namespace.
227 } // End llvm namespace.