mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 13:18:04 +02:00
radeon/llvm: replace shader type intrinsic with function attribute
Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
parent
de80e560bc
commit
b8f4ca3d85
3 changed files with 26 additions and 12 deletions
|
|
@ -28,10 +28,12 @@
|
||||||
#if HAVE_LLVM < 0x0303
|
#if HAVE_LLVM < 0x0303
|
||||||
#include <llvm/LLVMContext.h>
|
#include <llvm/LLVMContext.h>
|
||||||
#include <llvm/Module.h>
|
#include <llvm/Module.h>
|
||||||
|
#include <llvm/Function.h>
|
||||||
#include <llvm/DataLayout.h>
|
#include <llvm/DataLayout.h>
|
||||||
#else
|
#else
|
||||||
#include <llvm/IR/LLVMContext.h>
|
#include <llvm/IR/LLVMContext.h>
|
||||||
#include <llvm/IR/Module.h>
|
#include <llvm/IR/Module.h>
|
||||||
|
#include <llvm/IR/Function.h>
|
||||||
#include <llvm/IR/DataLayout.h>
|
#include <llvm/IR/DataLayout.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -68,6 +70,26 @@ static LLVMEnsureMultithreaded lLVMEnsureMultithreaded;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the shader type we want to compile
|
||||||
|
*
|
||||||
|
* @param type shader type to set
|
||||||
|
*/
|
||||||
|
extern "C" void
|
||||||
|
radeon_llvm_shader_type(LLVMValueRef F, unsigned type)
|
||||||
|
{
|
||||||
|
Function *Func = unwrap<Function>(F);
|
||||||
|
int Idx = AttributeSet::FunctionIndex;
|
||||||
|
AttrBuilder B;
|
||||||
|
char Str[2];
|
||||||
|
|
||||||
|
sprintf(Str, "%1d", type);
|
||||||
|
B.addAttribute("ShaderType", Str);
|
||||||
|
|
||||||
|
AttributeSet Set = AttributeSet::get(Func->getContext(), Idx, B);
|
||||||
|
Func->addAttributes(Idx, Set);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile an LLVM module to machine code.
|
* Compile an LLVM module to machine code.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void radeon_llvm_shader_type(LLVMValueRef F, unsigned type);
|
||||||
|
|
||||||
unsigned radeon_llvm_bitcode_compile(
|
unsigned radeon_llvm_bitcode_compile(
|
||||||
unsigned char * bitcode, unsigned bitcode_len,
|
unsigned char * bitcode, unsigned bitcode_len,
|
||||||
unsigned char ** bytes, unsigned * byte_count,
|
unsigned char ** bytes, unsigned * byte_count,
|
||||||
|
|
|
||||||
|
|
@ -542,17 +542,6 @@ static void si_llvm_init_export_args(struct lp_build_tgsi_context *bld_base,
|
||||||
* stage. */
|
* stage. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void si_llvm_emit_prologue(struct lp_build_tgsi_context *bld_base)
|
|
||||||
{
|
|
||||||
struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
|
|
||||||
struct gallivm_state *gallivm = bld_base->base.gallivm;
|
|
||||||
lp_build_intrinsic_unary(gallivm->builder,
|
|
||||||
"llvm.AMDGPU.shader.type",
|
|
||||||
LLVMVoidTypeInContext(gallivm->context),
|
|
||||||
lp_build_const_int32(gallivm, si_shader_ctx->type));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void si_alpha_test(struct lp_build_tgsi_context *bld_base,
|
static void si_alpha_test(struct lp_build_tgsi_context *bld_base,
|
||||||
unsigned index)
|
unsigned index)
|
||||||
{
|
{
|
||||||
|
|
@ -1032,7 +1021,6 @@ int si_pipe_shader_create(
|
||||||
shader->shader.uses_kill = shader_info.uses_kill;
|
shader->shader.uses_kill = shader_info.uses_kill;
|
||||||
bld_base->info = &shader_info;
|
bld_base->info = &shader_info;
|
||||||
bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
|
bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
|
||||||
bld_base->emit_prologue = si_llvm_emit_prologue;
|
|
||||||
bld_base->emit_epilogue = si_llvm_emit_epilogue;
|
bld_base->emit_epilogue = si_llvm_emit_epilogue;
|
||||||
|
|
||||||
bld_base->op_actions[TGSI_OPCODE_TEX] = tex_action;
|
bld_base->op_actions[TGSI_OPCODE_TEX] = tex_action;
|
||||||
|
|
@ -1048,6 +1036,8 @@ int si_pipe_shader_create(
|
||||||
si_shader_ctx.type = si_shader_ctx.parse.FullHeader.Processor.Processor;
|
si_shader_ctx.type = si_shader_ctx.parse.FullHeader.Processor.Processor;
|
||||||
si_shader_ctx.rctx = rctx;
|
si_shader_ctx.rctx = rctx;
|
||||||
|
|
||||||
|
radeon_llvm_shader_type(si_shader_ctx.radeon_bld.main_fn, si_shader_ctx.type);
|
||||||
|
|
||||||
shader->shader.nr_cbufs = rctx->framebuffer.nr_cbufs;
|
shader->shader.nr_cbufs = rctx->framebuffer.nr_cbufs;
|
||||||
|
|
||||||
/* Dump TGSI code before doing TGSI->LLVM conversion in case the
|
/* Dump TGSI code before doing TGSI->LLVM conversion in case the
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue