amd/common: add ac_is_sgpr_param helper
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 28 Oct 2016 12:40:24 +0000 (14:40 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 3 Nov 2016 09:06:27 +0000 (10:06 +0100)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_llvm_helper.cpp
src/amd/common/ac_llvm_util.h

index 125f5f3d7a9d7594eccddb4a8425ce67ad287fa7..594339ee8c8182b9c8613a9bf940d71fbd90ed14 100644 (file)
@@ -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);
+}
index 25ebc503ac7a16ab094c784b3ca0f28c970d978a..d9ea9bd185a0e709c2969d2a9218992c57c5e40a 100644 (file)
@@ -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
 }