[Mesa-dev] [PATCH 03/31] amd/common: add ac_is_sgpr_param helper
Nicolai Hähnle
nhaehnle at gmail.com
Mon Oct 31 22:10:50 UTC 2016
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
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 125f5f3..594339e 100644
--- a/src/amd/common/ac_llvm_helper.cpp
+++ b/src/amd/common/ac_llvm_helper.cpp
@@ -28,18 +28,28 @@
// Workaround http://llvm.org/PR23628
#if HAVE_LLVM >= 0x0307
# pragma push_macro("DEBUG")
# undef DEBUG
#endif
#include "ac_llvm_util.h"
#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)
{
llvm::Argument *A = llvm::unwrap<llvm::Argument>(val);
llvm::AttrBuilder B;
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 25ebc50..d9ea9bd 100644
--- a/src/amd/common/ac_llvm_util.h
+++ b/src/amd/common/ac_llvm_util.h
@@ -17,25 +17,27 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*/
#pragma once
+#include <stdbool.h>
#include <llvm-c/TargetMachine.h>
#include "amd_family.h"
#ifdef __cplusplus
extern "C" {
#endif
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
}
#endif
--
2.7.4
More information about the mesa-dev
mailing list