2
2
* Copyright 2014 Advanced Micro Devices, Inc.
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the
6
* "Software"), to deal in the Software without restriction, including
7
* without limitation the rights to use, copy, modify, merge, publish,
8
* distribute, sub license, and/or sell copies of the Software, and to
9
* permit persons to whom the Software is furnished to do so, subject to
10
* the following conditions:
12
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
15
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
16
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
* USE OR OTHER DEALINGS IN THE SOFTWARE.
20
* The above copyright notice and this permission notice (including the
21
* next paragraph) shall be included in all copies or substantial portions
4
* SPDX-License-Identifier: MIT
25
6
/* based on pieces from si_pipe.c and radeon_llvm_emit.c */
26
7
#include "ac_llvm_util.h"
53
34
/* error messages prefix */
55
36
"-amdgpu-atomic-optimizations=true",
56
#if LLVM_VERSION_MAJOR == 11
57
/* This fixes variable indexing on LLVM 11. It also breaks atomic.cmpswap on LLVM >= 12. */
58
"-structurizecfg-skip-uniform-regions",
62
ac_reset_llvm_all_options_occurences();
39
ac_reset_llvm_all_options_occurrences();
63
40
LLVMParseCommandLineOptions(ARRAY_SIZE(argv), argv, NULL);
65
42
ac_llvm_run_atexit_for_destructors();
167
144
case CHIP_NAVI21:
168
145
return "gfx1030";
169
146
case CHIP_NAVI22:
170
return LLVM_VERSION_MAJOR >= 12 ? "gfx1031" : "gfx1030";
171
148
case CHIP_NAVI23:
172
return LLVM_VERSION_MAJOR >= 12 ? "gfx1032" : "gfx1030";
173
150
case CHIP_VANGOGH:
174
return LLVM_VERSION_MAJOR >= 12 ? "gfx1033" : "gfx1030";
175
152
case CHIP_NAVI24:
176
return LLVM_VERSION_MAJOR >= 13 ? "gfx1034" : "gfx1030";
177
154
case CHIP_REMBRANDT:
178
return LLVM_VERSION_MAJOR >= 13 ? "gfx1035" : "gfx1030";
179
156
case CHIP_RAPHAEL_MENDOCINO:
180
return LLVM_VERSION_MAJOR >= 15 ? "gfx1036" : "gfx1030";
181
158
case CHIP_GFX1100:
182
159
return "gfx1100";
183
160
case CHIP_GFX1101:
255
232
LLVMAddTargetDependentFunctionAttr(F, "amdgpu-flat-work-group-size", str);
258
void ac_llvm_set_target_features(LLVMValueRef F, struct ac_llvm_context *ctx)
235
void ac_llvm_set_target_features(LLVMValueRef F, struct ac_llvm_context *ctx, bool wgp_mode)
260
237
char features[2048];
262
snprintf(features, sizeof(features), "+DumpCode%s%s",
239
snprintf(features, sizeof(features), "+DumpCode%s%s%s",
263
240
/* GFX9 has broken VGPR indexing, so always promote alloca to scratch. */
264
241
ctx->gfx_level == GFX9 ? ",-promote-alloca" : "",
265
242
/* Wave32 is the default. */
266
243
ctx->gfx_level >= GFX10 && ctx->wave_size == 64 ?
267
",+wavefrontsize64,-wavefrontsize32" : "");
244
",+wavefrontsize64,-wavefrontsize32" : "",
245
ctx->gfx_level >= GFX10 && !wgp_mode ? ",+cumode" : "");
269
247
LLVMAddTargetDependentFunctionAttr(F, "target-features", features);