From 908100cfae88a9e83560919018fc8a8a3a7bf745 Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Fri, 28 Oct 2016 14:40:24 +0200 Subject: amd/common: add ac_is_sgpr_param helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Dave Airlie Reviewed-by: Marek Olšák --- src/amd/common/ac_llvm_helper.cpp | 10 ++++++++++ src/amd/common/ac_llvm_util.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/amd/common/ac_llvm_helper.cpp b/src/amd/common/ac_llvm_helper.cpp index 125f5f3d7a9..594339ee8c8 100644 --- a/src/amd/common/ac_llvm_helper.cpp +++ b/src/amd/common/ac_llvm_helper.cpp @@ -35,6 +35,7 @@ #include #include #include +#include void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes) { @@ -43,3 +44,12 @@ void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes) B.addDereferenceableAttr(bytes); A->addAttr(llvm::AttributeSet::get(A->getContext(), A->getArgNo() + 1, B)); } + +bool ac_is_sgpr_param(LLVMValueRef arg) +{ + llvm::Argument *A = llvm::unwrap(arg); + llvm::AttributeSet AS = A->getParent()->getAttributes(); + unsigned ArgNo = A->getArgNo(); + return AS.hasAttribute(ArgNo + 1, llvm::Attribute::ByVal) || + AS.hasAttribute(ArgNo + 1, llvm::Attribute::InReg); +} diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h index 25ebc503ac7..d9ea9bd185a 100644 --- a/src/amd/common/ac_llvm_util.h +++ b/src/amd/common/ac_llvm_util.h @@ -24,6 +24,7 @@ */ #pragma once +#include #include #include "amd_family.h" @@ -35,6 +36,7 @@ extern "C" { LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family); void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes); +bool ac_is_sgpr_param(LLVMValueRef param); #ifdef __cplusplus } -- cgit v1.2.3