~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/amd/llvm/ac_llvm_util.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Copyright 2014 Advanced Micro Devices, Inc.
3
3
 *
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:
11
 
 *
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.
19
 
 *
20
 
 * The above copyright notice and this permission notice (including the
21
 
 * next paragraph) shall be included in all copies or substantial portions
22
 
 * of the Software.
23
 
 *
 
4
 * SPDX-License-Identifier: MIT
24
5
 */
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 */
54
35
      "mesa",
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",
59
 
#endif
60
37
   };
61
38
 
62
 
   ac_reset_llvm_all_options_occurences();
 
39
   ac_reset_llvm_all_options_occurrences();
63
40
   LLVMParseCommandLineOptions(ARRAY_SIZE(argv), argv, NULL);
64
41
 
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";
 
147
      return "gfx1031";
171
148
   case CHIP_NAVI23:
172
 
      return LLVM_VERSION_MAJOR >= 12 ? "gfx1032" : "gfx1030";
 
149
      return "gfx1032";
173
150
   case CHIP_VANGOGH:
174
 
      return LLVM_VERSION_MAJOR >= 12 ? "gfx1033" : "gfx1030";
 
151
      return "gfx1033";
175
152
   case CHIP_NAVI24:
176
 
      return LLVM_VERSION_MAJOR >= 13 ? "gfx1034" : "gfx1030";
 
153
      return "gfx1034";
177
154
   case CHIP_REMBRANDT:
178
 
      return LLVM_VERSION_MAJOR >= 13 ? "gfx1035" : "gfx1030";
 
155
      return "gfx1035";
179
156
   case CHIP_RAPHAEL_MENDOCINO:
180
 
      return LLVM_VERSION_MAJOR >= 15 ? "gfx1036" : "gfx1030";
 
157
      return "gfx1036";
181
158
   case CHIP_GFX1100:
182
159
      return "gfx1100";
183
160
   case CHIP_GFX1101:
255
232
   LLVMAddTargetDependentFunctionAttr(F, "amdgpu-flat-work-group-size", str);
256
233
}
257
234
 
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)
259
236
{
260
237
   char features[2048];
261
238
 
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" : "");
268
246
 
269
247
   LLVMAddTargetDependentFunctionAttr(F, "target-features", features);
270
248
}