forked from OSchip/llvm-project
Expose parameter attributes via C bindings.
Patch by Anders Johnsen! llvm-svn: 50360
This commit is contained in:
parent
da44054867
commit
2d9cc2197a
|
@ -82,6 +82,20 @@ typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
|
||||||
/** See the llvm::PassManagerBase class. */
|
/** See the llvm::PassManagerBase class. */
|
||||||
typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
|
typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
LLVMZExtParamAttr = 1<<0,
|
||||||
|
LLVMSExtParamAttr = 1<<1,
|
||||||
|
LLVMNoReturnParamAttr = 1<<2,
|
||||||
|
LLVMNoUnwindParamAttr = 1<<3,
|
||||||
|
LLVMInRegParamAttr = 1<<4,
|
||||||
|
LLVMNoAliasParamAttr = 1<<5,
|
||||||
|
LLVMStructRetParamAttr = 1<<6,
|
||||||
|
LLVMByValParamAttr = 1<<7,
|
||||||
|
LLVMNestParamAttr = 1<<8,
|
||||||
|
LLVMReadNoneParamAttr = 1<<9,
|
||||||
|
LLVMReadOnlyParamAttr = 1<<10
|
||||||
|
} LLVMParamAttr;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LLVMVoidTypeKind, /**< type with no size */
|
LLVMVoidTypeKind, /**< type with no size */
|
||||||
LLVMFloatTypeKind, /**< 32 bit floating point type */
|
LLVMFloatTypeKind, /**< 32 bit floating point type */
|
||||||
|
@ -413,6 +427,9 @@ LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
|
||||||
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
|
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
|
||||||
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
|
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
|
||||||
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
|
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
|
||||||
|
void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA);
|
||||||
|
void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA);
|
||||||
|
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
|
||||||
|
|
||||||
/* Operations on basic blocks */
|
/* Operations on basic blocks */
|
||||||
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
|
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
|
||||||
|
@ -441,6 +458,11 @@ LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
|
||||||
/* Operations on call sites */
|
/* Operations on call sites */
|
||||||
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
|
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
|
||||||
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
|
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
|
||||||
|
void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index, LLVMParamAttr);
|
||||||
|
void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index,
|
||||||
|
LLVMParamAttr);
|
||||||
|
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
|
||||||
|
unsigned align);
|
||||||
|
|
||||||
/* Operations on phi nodes */
|
/* Operations on phi nodes */
|
||||||
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
|
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#define LLVM_ARGUMENT_H
|
#define LLVM_ARGUMENT_H
|
||||||
|
|
||||||
#include "llvm/Value.h"
|
#include "llvm/Value.h"
|
||||||
|
#include "llvm/ParameterAttributes.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
@ -61,6 +62,12 @@ public:
|
||||||
/// its containing function.
|
/// its containing function.
|
||||||
bool hasStructRetAttr() const;
|
bool hasStructRetAttr() const;
|
||||||
|
|
||||||
|
/// addAttr - Add a ParamAttr to an argument
|
||||||
|
void addAttr(ParameterAttributes);
|
||||||
|
|
||||||
|
/// removeAttr - Remove a ParamAttr from an argument
|
||||||
|
void removeAttr(ParameterAttributes);
|
||||||
|
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::ostream &OS) const;
|
||||||
void print(std::ostream *OS) const {
|
void print(std::ostream *OS) const {
|
||||||
if (OS) print(*OS);
|
if (OS) print(*OS);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "llvm/TypeSymbolTable.h"
|
#include "llvm/TypeSymbolTable.h"
|
||||||
#include "llvm/ModuleProvider.h"
|
#include "llvm/ModuleProvider.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
#include "llvm/Support/CallSite.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -798,6 +799,19 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) {
|
||||||
return wrap(--I);
|
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 ..........................................--*/
|
/*--.. Operations on basic blocks ..........................................--*/
|
||||||
|
|
||||||
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) {
|
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) {
|
||||||
|
@ -936,6 +950,28 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
|
||||||
assert(0 && "LLVMSetInstructionCallConv applies only to call and invoke!");
|
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 .............................................--*/
|
/*--.. Operations on phi nodes .............................................--*/
|
||||||
|
|
||||||
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
|
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
|
||||||
|
|
|
@ -110,6 +110,17 @@ bool Argument::hasStructRetAttr() const {
|
||||||
return getParent()->paramHasAttr(1, ParamAttr::StructRet);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue