diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2008-04-28 17:37:06 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2008-04-28 17:37:06 +0000 |
commit | e2435da8abe5ca62c7f08f29c242b6b98e0ec7af (patch) | |
tree | 66e5cc5aa713285dde8e0d76592f695810cd847a /lib/VMCore | |
parent | 1f13c686df75ddbbe15b208606ece4846d7479a8 (diff) | |
download | external_llvm-e2435da8abe5ca62c7f08f29c242b6b98e0ec7af.zip external_llvm-e2435da8abe5ca62c7f08f29c242b6b98e0ec7af.tar.gz external_llvm-e2435da8abe5ca62c7f08f29c242b6b98e0ec7af.tar.bz2 |
Expose parameter attributes via C bindings.
Patch by Anders Johnsen!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50360 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Core.cpp | 36 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 11 |
2 files changed, 47 insertions, 0 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index ad72095..a07464f 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -20,6 +20,7 @@ #include "llvm/TypeSymbolTable.h" #include "llvm/ModuleProvider.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/CallSite.h" #include <cassert> #include <cstdlib> #include <cstring> @@ -798,6 +799,19 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) { return wrap(--I); } +void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) { + unwrap<Argument>(Arg)->addAttr(PA); +} + +void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) { + unwrap<Argument>(Arg)->removeAttr(PA); +} + +void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) { + unwrap<Argument>(Arg)->addAttr( + ParamAttr::constructAlignmentFromInt(align)); +} + /*--.. Operations on basic blocks ..........................................--*/ LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) { @@ -936,6 +950,28 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) { assert(0 && "LLVMSetInstructionCallConv applies only to call and invoke!"); } +void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index, + LLVMParamAttr PA) { + CallSite Call = CallSite(unwrap<Instruction>(Instr)); + Call.setParamAttrs( + Call.getParamAttrs().addAttr(index, PA)); +} + +void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index, + LLVMParamAttr PA) { + CallSite Call = CallSite(unwrap<Instruction>(Instr)); + Call.setParamAttrs( + Call.getParamAttrs().removeAttr(index, PA)); +} + +void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, + unsigned align) { + CallSite Call = CallSite(unwrap<Instruction>(Instr)); + Call.setParamAttrs( + Call.getParamAttrs().addAttr(index, + ParamAttr::constructAlignmentFromInt(align))); +} + /*--.. Operations on phi nodes .............................................--*/ void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index de011c0..f14c455 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -110,6 +110,17 @@ bool Argument::hasStructRetAttr() const { return getParent()->paramHasAttr(1, ParamAttr::StructRet); } +/// addAttr - Add a ParamAttr to an argument +void Argument::addAttr(ParameterAttributes attr) { + getParent()->setParamAttrs( + getParent()->getParamAttrs().addAttr(getArgNo() + 1, attr)); +} + +/// removeAttr - Remove a ParamAttr from an argument +void Argument::removeAttr(ParameterAttributes attr) { + getParent()->setParamAttrs( + getParent()->getParamAttrs().removeAttr(getArgNo() + 1, attr)); +} |