summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2016-10-28 14:40:24 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2016-11-02 12:36:26 +0100
commitc9a677685b0b57983d98d8f5b4dddbe665bcaabc (patch)
tree633b8658b0a9a7d31257206311da0616d5df6eea
parent1b1fc8adc717182d7495be97a3d84eff6eb4f86a (diff)
amd/common: add ac_is_sgpr_param helper
-rw-r--r--src/amd/common/ac_llvm_helper.cpp10
-rw-r--r--src/amd/common/ac_llvm_util.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/src/amd/common/ac_llvm_helper.cpp b/src/amd/common/ac_llvm_helper.cpp
index 125f5f3d7a..594339ee8c 100644
--- a/src/amd/common/ac_llvm_helper.cpp
+++ b/src/amd/common/ac_llvm_helper.cpp
@@ -35,6 +35,7 @@
#include <llvm-c/Core.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
+#include <llvm/IR/Attributes.h>
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<llvm::Argument>(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 25ebc503ac..d9ea9bd185 100644
--- a/src/amd/common/ac_llvm_util.h
+++ b/src/amd/common/ac_llvm_util.h
@@ -24,6 +24,7 @@
*/
#pragma once
+#include <stdbool.h>
#include <llvm-c/TargetMachine.h>
#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
}