xref: /src/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIModeRegisterDefaults.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
17fa27ce4SDimitry Andric //===-- SIModeRegisterDefaults.cpp ------------------------------*- C++ -*-===//
27fa27ce4SDimitry Andric //
37fa27ce4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47fa27ce4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
57fa27ce4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67fa27ce4SDimitry Andric //
77fa27ce4SDimitry Andric //===----------------------------------------------------------------------===//
87fa27ce4SDimitry Andric 
97fa27ce4SDimitry Andric #include "SIModeRegisterDefaults.h"
10312c0ed1SDimitry Andric #include "GCNSubtarget.h"
117fa27ce4SDimitry Andric 
127fa27ce4SDimitry Andric using namespace llvm;
137fa27ce4SDimitry Andric 
SIModeRegisterDefaults(const Function & F,const GCNSubtarget & ST)14312c0ed1SDimitry Andric SIModeRegisterDefaults::SIModeRegisterDefaults(const Function &F,
15312c0ed1SDimitry Andric                                                const GCNSubtarget &ST) {
167fa27ce4SDimitry Andric   *this = getDefaultForCallingConv(F.getCallingConv());
177fa27ce4SDimitry Andric 
18312c0ed1SDimitry Andric   if (ST.hasIEEEMode()) {
197fa27ce4SDimitry Andric     StringRef IEEEAttr = F.getFnAttribute("amdgpu-ieee").getValueAsString();
207fa27ce4SDimitry Andric     if (!IEEEAttr.empty())
217fa27ce4SDimitry Andric       IEEE = IEEEAttr == "true";
22312c0ed1SDimitry Andric   }
237fa27ce4SDimitry Andric 
24312c0ed1SDimitry Andric   if (ST.hasDX10ClampMode()) {
257fa27ce4SDimitry Andric     StringRef DX10ClampAttr =
267fa27ce4SDimitry Andric         F.getFnAttribute("amdgpu-dx10-clamp").getValueAsString();
277fa27ce4SDimitry Andric     if (!DX10ClampAttr.empty())
287fa27ce4SDimitry Andric       DX10Clamp = DX10ClampAttr == "true";
29312c0ed1SDimitry Andric   }
307fa27ce4SDimitry Andric 
317fa27ce4SDimitry Andric   StringRef DenormF32Attr =
327fa27ce4SDimitry Andric       F.getFnAttribute("denormal-fp-math-f32").getValueAsString();
337fa27ce4SDimitry Andric   if (!DenormF32Attr.empty())
347fa27ce4SDimitry Andric     FP32Denormals = parseDenormalFPAttribute(DenormF32Attr);
357fa27ce4SDimitry Andric 
367fa27ce4SDimitry Andric   StringRef DenormAttr =
377fa27ce4SDimitry Andric       F.getFnAttribute("denormal-fp-math").getValueAsString();
387fa27ce4SDimitry Andric   if (!DenormAttr.empty()) {
397fa27ce4SDimitry Andric     DenormalMode DenormMode = parseDenormalFPAttribute(DenormAttr);
407fa27ce4SDimitry Andric     if (DenormF32Attr.empty())
417fa27ce4SDimitry Andric       FP32Denormals = DenormMode;
427fa27ce4SDimitry Andric     FP64FP16Denormals = DenormMode;
437fa27ce4SDimitry Andric   }
447fa27ce4SDimitry Andric }
45b1c73532SDimitry Andric 
46b1c73532SDimitry Andric using namespace AMDGPU;
47b1c73532SDimitry Andric 
48b1c73532SDimitry Andric /// Combine f32 and f64 rounding modes into a combined rounding mode value.
getModeRegisterRoundMode(uint32_t HWFP32Val,uint32_t HWFP64Val)49b1c73532SDimitry Andric static constexpr uint32_t getModeRegisterRoundMode(uint32_t HWFP32Val,
50b1c73532SDimitry Andric                                                    uint32_t HWFP64Val) {
51b1c73532SDimitry Andric   return HWFP32Val << F32FltRoundOffset | HWFP64Val << F64FltRoundOffset;
52b1c73532SDimitry Andric }
53b1c73532SDimitry Andric 
encodeFltRoundsTable(uint32_t FltRoundsVal,uint32_t HWF32Val,uint32_t HWF64Val)54b1c73532SDimitry Andric static constexpr uint64_t encodeFltRoundsTable(uint32_t FltRoundsVal,
55b1c73532SDimitry Andric                                                uint32_t HWF32Val,
56b1c73532SDimitry Andric                                                uint32_t HWF64Val) {
57b1c73532SDimitry Andric   uint32_t ModeVal = getModeRegisterRoundMode(HWF32Val, HWF64Val);
58b1c73532SDimitry Andric   if (FltRoundsVal > TowardNegative)
59b1c73532SDimitry Andric     FltRoundsVal -= ExtendedFltRoundOffset;
60b1c73532SDimitry Andric 
61b1c73532SDimitry Andric   uint32_t BitIndex = ModeVal << 2;
62b1c73532SDimitry Andric   return static_cast<uint64_t>(FltRoundsVal) << BitIndex;
63b1c73532SDimitry Andric }
64b1c73532SDimitry Andric 
65b1c73532SDimitry Andric // Encode FLT_ROUNDS value where the two rounding modes are the same and use a
66b1c73532SDimitry Andric // standard value
67b1c73532SDimitry Andric static constexpr uint64_t
encodeFltRoundsTableSame(AMDGPUFltRounds FltRoundsMode,uint32_t HWVal)68b1c73532SDimitry Andric encodeFltRoundsTableSame(AMDGPUFltRounds FltRoundsMode, uint32_t HWVal) {
69b1c73532SDimitry Andric   return encodeFltRoundsTable(FltRoundsMode, HWVal, HWVal);
70b1c73532SDimitry Andric }
71b1c73532SDimitry Andric 
72b1c73532SDimitry Andric // Convert mode register encoded rounding mode to AMDGPUFltRounds
73b1c73532SDimitry Andric static constexpr AMDGPUFltRounds
decodeIndexFltRoundConversionTable(uint32_t HWMode)74b1c73532SDimitry Andric decodeIndexFltRoundConversionTable(uint32_t HWMode) {
75b1c73532SDimitry Andric   uint32_t TableRead = (FltRoundConversionTable >> (HWMode << 2)) & 0xf;
76b1c73532SDimitry Andric   if (TableRead > TowardNegative)
77b1c73532SDimitry Andric     TableRead += ExtendedFltRoundOffset;
78b1c73532SDimitry Andric   return static_cast<AMDGPUFltRounds>(TableRead);
79b1c73532SDimitry Andric }
80b1c73532SDimitry Andric 
81b1c73532SDimitry Andric static constexpr uint32_t HWTowardZero = FP_ROUND_ROUND_TO_ZERO;
82b1c73532SDimitry Andric static constexpr uint32_t HWNearestTiesToEven = FP_ROUND_ROUND_TO_NEAREST;
83b1c73532SDimitry Andric static constexpr uint32_t HWTowardPositive = FP_ROUND_ROUND_TO_INF;
84b1c73532SDimitry Andric static constexpr uint32_t HWTowardNegative = FP_ROUND_ROUND_TO_NEGINF;
85b1c73532SDimitry Andric 
86b1c73532SDimitry Andric const uint64_t AMDGPU::FltRoundConversionTable =
87b1c73532SDimitry Andric     encodeFltRoundsTableSame(TowardZeroF32_TowardZeroF64, HWTowardZero) |
88b1c73532SDimitry Andric     encodeFltRoundsTableSame(NearestTiesToEvenF32_NearestTiesToEvenF64,
89b1c73532SDimitry Andric                              HWNearestTiesToEven) |
90b1c73532SDimitry Andric     encodeFltRoundsTableSame(TowardPositiveF32_TowardPositiveF64,
91b1c73532SDimitry Andric                              HWTowardPositive) |
92b1c73532SDimitry Andric     encodeFltRoundsTableSame(TowardNegativeF32_TowardNegativeF64,
93b1c73532SDimitry Andric                              HWTowardNegative) |
94b1c73532SDimitry Andric 
95b1c73532SDimitry Andric     encodeFltRoundsTable(TowardZeroF32_NearestTiesToEvenF64, HWTowardZero,
96b1c73532SDimitry Andric                          HWNearestTiesToEven) |
97b1c73532SDimitry Andric     encodeFltRoundsTable(TowardZeroF32_TowardPositiveF64, HWTowardZero,
98b1c73532SDimitry Andric                          HWTowardPositive) |
99b1c73532SDimitry Andric     encodeFltRoundsTable(TowardZeroF32_TowardNegativeF64, HWTowardZero,
100b1c73532SDimitry Andric                          HWTowardNegative) |
101b1c73532SDimitry Andric 
102b1c73532SDimitry Andric     encodeFltRoundsTable(NearestTiesToEvenF32_TowardZeroF64,
103b1c73532SDimitry Andric                          HWNearestTiesToEven, HWTowardZero) |
104b1c73532SDimitry Andric     encodeFltRoundsTable(NearestTiesToEvenF32_TowardPositiveF64,
105b1c73532SDimitry Andric                          HWNearestTiesToEven, HWTowardPositive) |
106b1c73532SDimitry Andric     encodeFltRoundsTable(NearestTiesToEvenF32_TowardNegativeF64,
107b1c73532SDimitry Andric                          HWNearestTiesToEven, HWTowardNegative) |
108b1c73532SDimitry Andric 
109b1c73532SDimitry Andric     encodeFltRoundsTable(TowardPositiveF32_TowardZeroF64, HWTowardPositive,
110b1c73532SDimitry Andric                          HWTowardZero) |
111b1c73532SDimitry Andric     encodeFltRoundsTable(TowardPositiveF32_NearestTiesToEvenF64,
112b1c73532SDimitry Andric                          HWTowardPositive, HWNearestTiesToEven) |
113b1c73532SDimitry Andric     encodeFltRoundsTable(TowardPositiveF32_TowardNegativeF64, HWTowardPositive,
114b1c73532SDimitry Andric                          HWTowardNegative) |
115b1c73532SDimitry Andric 
116b1c73532SDimitry Andric     encodeFltRoundsTable(TowardNegativeF32_TowardZeroF64, HWTowardNegative,
117b1c73532SDimitry Andric                          HWTowardZero) |
118b1c73532SDimitry Andric     encodeFltRoundsTable(TowardNegativeF32_NearestTiesToEvenF64,
119b1c73532SDimitry Andric                          HWTowardNegative, HWNearestTiesToEven) |
120b1c73532SDimitry Andric     encodeFltRoundsTable(TowardNegativeF32_TowardPositiveF64, HWTowardNegative,
121b1c73532SDimitry Andric                          HWTowardPositive);
122b1c73532SDimitry Andric 
123b1c73532SDimitry Andric // Verify evaluation of FltRoundConversionTable
124b1c73532SDimitry Andric 
125b1c73532SDimitry Andric // If both modes are the same, should return the standard values.
126b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
127b1c73532SDimitry Andric                   HWTowardZero, HWTowardZero)) == AMDGPUFltRounds::TowardZero);
128b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
129b1c73532SDimitry Andric                   HWNearestTiesToEven, HWNearestTiesToEven)) ==
130b1c73532SDimitry Andric               AMDGPUFltRounds::NearestTiesToEven);
131b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
132b1c73532SDimitry Andric                   HWTowardPositive, HWTowardPositive)) ==
133b1c73532SDimitry Andric               AMDGPUFltRounds::TowardPositive);
134b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
135b1c73532SDimitry Andric                   HWTowardNegative, HWTowardNegative)) ==
136b1c73532SDimitry Andric               AMDGPUFltRounds::TowardNegative);
137b1c73532SDimitry Andric 
138b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
139b1c73532SDimitry Andric                   HWTowardZero, HWNearestTiesToEven)) ==
140b1c73532SDimitry Andric               TowardZeroF32_NearestTiesToEvenF64);
141b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(
142b1c73532SDimitry Andric                   getModeRegisterRoundMode(HWTowardZero, HWTowardPositive)) ==
143b1c73532SDimitry Andric               TowardZeroF32_TowardPositiveF64);
144b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(
145b1c73532SDimitry Andric                   getModeRegisterRoundMode(HWTowardZero, HWTowardNegative)) ==
146b1c73532SDimitry Andric               TowardZeroF32_TowardNegativeF64);
147b1c73532SDimitry Andric 
148b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
149b1c73532SDimitry Andric                   HWNearestTiesToEven, HWTowardZero)) ==
150b1c73532SDimitry Andric               NearestTiesToEvenF32_TowardZeroF64);
151b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
152b1c73532SDimitry Andric                   HWNearestTiesToEven, HWTowardPositive)) ==
153b1c73532SDimitry Andric               NearestTiesToEvenF32_TowardPositiveF64);
154b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
155b1c73532SDimitry Andric                   HWNearestTiesToEven, HWTowardNegative)) ==
156b1c73532SDimitry Andric               NearestTiesToEvenF32_TowardNegativeF64);
157b1c73532SDimitry Andric 
158b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(
159b1c73532SDimitry Andric                   getModeRegisterRoundMode(HWTowardPositive, HWTowardZero)) ==
160b1c73532SDimitry Andric               TowardPositiveF32_TowardZeroF64);
161b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
162b1c73532SDimitry Andric                   HWTowardPositive, HWNearestTiesToEven)) ==
163b1c73532SDimitry Andric               TowardPositiveF32_NearestTiesToEvenF64);
164b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
165b1c73532SDimitry Andric                   HWTowardPositive, HWTowardNegative)) ==
166b1c73532SDimitry Andric               TowardPositiveF32_TowardNegativeF64);
167b1c73532SDimitry Andric 
168b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(
169b1c73532SDimitry Andric                   getModeRegisterRoundMode(HWTowardNegative, HWTowardZero)) ==
170b1c73532SDimitry Andric               TowardNegativeF32_TowardZeroF64);
171b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
172b1c73532SDimitry Andric                   HWTowardNegative, HWNearestTiesToEven)) ==
173b1c73532SDimitry Andric               TowardNegativeF32_NearestTiesToEvenF64);
174b1c73532SDimitry Andric static_assert(decodeIndexFltRoundConversionTable(getModeRegisterRoundMode(
175b1c73532SDimitry Andric                   HWTowardNegative, HWTowardPositive)) ==
176b1c73532SDimitry Andric               TowardNegativeF32_TowardPositiveF64);
177ac9a064cSDimitry Andric 
178ac9a064cSDimitry Andric // Decode FLT_ROUNDS into the hardware value where the two rounding modes are
179ac9a064cSDimitry Andric // the same and use a standard value
encodeFltRoundsToHWTableSame(uint32_t HWVal,uint32_t FltRoundsVal)180ac9a064cSDimitry Andric static constexpr uint64_t encodeFltRoundsToHWTableSame(uint32_t HWVal,
181ac9a064cSDimitry Andric                                                        uint32_t FltRoundsVal) {
182ac9a064cSDimitry Andric   if (FltRoundsVal > TowardNegative)
183ac9a064cSDimitry Andric     FltRoundsVal -= ExtendedFltRoundOffset;
184ac9a064cSDimitry Andric 
185ac9a064cSDimitry Andric   return static_cast<uint64_t>(getModeRegisterRoundMode(HWVal, HWVal))
186ac9a064cSDimitry Andric          << (FltRoundsVal << 2);
187ac9a064cSDimitry Andric }
188ac9a064cSDimitry Andric 
189ac9a064cSDimitry Andric /// Decode FLT_ROUNDS into the hardware value where the two rounding modes
190ac9a064cSDimitry Andric /// different and use an extended value.
encodeFltRoundsToHWTable(uint32_t HWF32Val,uint32_t HWF64Val,uint32_t FltRoundsVal)191ac9a064cSDimitry Andric static constexpr uint64_t encodeFltRoundsToHWTable(uint32_t HWF32Val,
192ac9a064cSDimitry Andric                                                    uint32_t HWF64Val,
193ac9a064cSDimitry Andric                                                    uint32_t FltRoundsVal) {
194ac9a064cSDimitry Andric   if (FltRoundsVal > TowardNegative)
195ac9a064cSDimitry Andric     FltRoundsVal -= ExtendedFltRoundOffset;
196ac9a064cSDimitry Andric   return static_cast<uint64_t>(getModeRegisterRoundMode(HWF32Val, HWF64Val))
197ac9a064cSDimitry Andric          << (FltRoundsVal << 2);
198ac9a064cSDimitry Andric }
199ac9a064cSDimitry Andric 
200ac9a064cSDimitry Andric const uint64_t AMDGPU::FltRoundToHWConversionTable =
201ac9a064cSDimitry Andric     encodeFltRoundsToHWTableSame(HWTowardZero, TowardZeroF32_TowardZeroF64) |
202ac9a064cSDimitry Andric     encodeFltRoundsToHWTableSame(HWNearestTiesToEven,
203ac9a064cSDimitry Andric                                  NearestTiesToEvenF32_NearestTiesToEvenF64) |
204ac9a064cSDimitry Andric     encodeFltRoundsToHWTableSame(HWTowardPositive,
205ac9a064cSDimitry Andric                                  TowardPositiveF32_TowardPositiveF64) |
206ac9a064cSDimitry Andric     encodeFltRoundsToHWTableSame(HWTowardNegative,
207ac9a064cSDimitry Andric                                  TowardNegativeF32_TowardNegativeF64) |
208ac9a064cSDimitry Andric 
209ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardZero, HWNearestTiesToEven,
210ac9a064cSDimitry Andric                              TowardZeroF32_NearestTiesToEvenF64) |
211ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardZero, HWTowardPositive,
212ac9a064cSDimitry Andric                              TowardZeroF32_TowardPositiveF64) |
213ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardZero, HWTowardNegative,
214ac9a064cSDimitry Andric                              TowardZeroF32_TowardNegativeF64) |
215ac9a064cSDimitry Andric 
216ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWNearestTiesToEven, HWTowardZero,
217ac9a064cSDimitry Andric                              NearestTiesToEvenF32_TowardZeroF64) |
218ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWNearestTiesToEven, HWTowardPositive,
219ac9a064cSDimitry Andric                              NearestTiesToEvenF32_TowardPositiveF64) |
220ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWNearestTiesToEven, HWTowardNegative,
221ac9a064cSDimitry Andric                              NearestTiesToEvenF32_TowardNegativeF64) |
222ac9a064cSDimitry Andric 
223ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardPositive, HWTowardZero,
224ac9a064cSDimitry Andric                              TowardPositiveF32_TowardZeroF64) |
225ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardPositive, HWNearestTiesToEven,
226ac9a064cSDimitry Andric                              TowardPositiveF32_NearestTiesToEvenF64) |
227ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardPositive, HWTowardNegative,
228ac9a064cSDimitry Andric                              TowardPositiveF32_TowardNegativeF64) |
229ac9a064cSDimitry Andric 
230ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardNegative, HWTowardZero,
231ac9a064cSDimitry Andric                              TowardNegativeF32_TowardZeroF64) |
232ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardNegative, HWNearestTiesToEven,
233ac9a064cSDimitry Andric                              TowardNegativeF32_NearestTiesToEvenF64) |
234ac9a064cSDimitry Andric     encodeFltRoundsToHWTable(HWTowardNegative, HWTowardPositive,
235ac9a064cSDimitry Andric                              TowardNegativeF32_TowardPositiveF64);
236ac9a064cSDimitry Andric 
237ac9a064cSDimitry Andric /// Read the hardware rounding mode equivalent of a AMDGPUFltRounds value.
238ac9a064cSDimitry Andric static constexpr uint32_t
decodeFltRoundToHWConversionTable(uint64_t FltRoundToHWConversionTable,uint32_t FltRounds)239ac9a064cSDimitry Andric decodeFltRoundToHWConversionTable(uint64_t FltRoundToHWConversionTable,
240ac9a064cSDimitry Andric                                   uint32_t FltRounds) {
241ac9a064cSDimitry Andric   uint32_t IndexVal = FltRounds;
242ac9a064cSDimitry Andric   if (IndexVal > TowardNegative)
243ac9a064cSDimitry Andric     IndexVal -= ExtendedFltRoundOffset;
244ac9a064cSDimitry Andric   return (FltRoundToHWConversionTable >> (IndexVal << 2)) & 0xf;
245ac9a064cSDimitry Andric }
246ac9a064cSDimitry Andric 
decodeFltRoundToHWConversionTable(uint32_t FltRounds)247ac9a064cSDimitry Andric uint32_t AMDGPU::decodeFltRoundToHWConversionTable(uint32_t FltRounds) {
248ac9a064cSDimitry Andric   return ::decodeFltRoundToHWConversionTable(FltRoundToHWConversionTable,
249ac9a064cSDimitry Andric                                              FltRounds);
250ac9a064cSDimitry Andric }
251ac9a064cSDimitry Andric 
decodeFltRoundToHW(uint32_t FltRounds)252ac9a064cSDimitry Andric static constexpr uint32_t decodeFltRoundToHW(uint32_t FltRounds) {
253ac9a064cSDimitry Andric   return ::decodeFltRoundToHWConversionTable(FltRoundToHWConversionTable,
254ac9a064cSDimitry Andric                                              FltRounds);
255ac9a064cSDimitry Andric }
256ac9a064cSDimitry Andric 
257ac9a064cSDimitry Andric // Verify evaluation of FltRoundToHWConversionTable
258ac9a064cSDimitry Andric 
259ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(AMDGPUFltRounds::TowardZero) ==
260ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardZero, HWTowardZero));
261ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(AMDGPUFltRounds::NearestTiesToEven) ==
262ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWNearestTiesToEven,
263ac9a064cSDimitry Andric                                        HWNearestTiesToEven));
264ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(AMDGPUFltRounds::TowardPositive) ==
265ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardPositive, HWTowardPositive));
266ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(AMDGPUFltRounds::TowardNegative) ==
267ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardNegative, HWTowardNegative));
268ac9a064cSDimitry Andric 
269ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(NearestTiesToEvenF32_TowardPositiveF64) ==
270ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWNearestTiesToEven, HWTowardPositive));
271ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(NearestTiesToEvenF32_TowardNegativeF64) ==
272ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWNearestTiesToEven, HWTowardNegative));
273ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(NearestTiesToEvenF32_TowardZeroF64) ==
274ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWNearestTiesToEven, HWTowardZero));
275ac9a064cSDimitry Andric 
276ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardPositiveF32_NearestTiesToEvenF64) ==
277ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardPositive, HWNearestTiesToEven));
278ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardPositiveF32_TowardNegativeF64) ==
279ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardPositive, HWTowardNegative));
280ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardPositiveF32_TowardZeroF64) ==
281ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardPositive, HWTowardZero));
282ac9a064cSDimitry Andric 
283ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardNegativeF32_NearestTiesToEvenF64) ==
284ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardNegative, HWNearestTiesToEven));
285ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardNegativeF32_TowardPositiveF64) ==
286ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardNegative, HWTowardPositive));
287ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardNegativeF32_TowardZeroF64) ==
288ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardNegative, HWTowardZero));
289ac9a064cSDimitry Andric 
290ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardZeroF32_NearestTiesToEvenF64) ==
291ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardZero, HWNearestTiesToEven));
292ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardZeroF32_TowardPositiveF64) ==
293ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardZero, HWTowardPositive));
294ac9a064cSDimitry Andric static_assert(decodeFltRoundToHW(TowardZeroF32_TowardNegativeF64) ==
295ac9a064cSDimitry Andric               getModeRegisterRoundMode(HWTowardZero, HWTowardNegative));
296