llvm.org GIT mirror llvm / e2435da
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 Gordon Henriksen 12 years ago
4 changed file(s) with 76 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1414 #define LLVM_ARGUMENT_H
1515
1616 #include "llvm/Value.h"
17 #include "llvm/ParameterAttributes.h"
1718
1819 namespace llvm {
1920
5960 /// hasSRetAttr - Return true if this argument has the sret attribute on it in
6061 /// its containing function.
6162 bool hasStructRetAttr() const;
63
64 /// addAttr - Add a ParamAttr to an argument
65 void addAttr(ParameterAttributes);
6266
67 /// removeAttr - Remove a ParamAttr from an argument
68 void removeAttr(ParameterAttributes);
69
6370 virtual void print(std::ostream &OS) const;
6471 void print(std::ostream *OS) const {
6572 if (OS) print(*OS);
8080
8181 /** See the llvm::PassManagerBase class. */
8282 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
83
84 typedef enum {
85 LLVMZExtParamAttr = 1<<0,
86 LLVMSExtParamAttr = 1<<1,
87 LLVMNoReturnParamAttr = 1<<2,
88 LLVMNoUnwindParamAttr = 1<<3,
89 LLVMInRegParamAttr = 1<<4,
90 LLVMNoAliasParamAttr = 1<<5,
91 LLVMStructRetParamAttr = 1<<6,
92 LLVMByValParamAttr = 1<<7,
93 LLVMNestParamAttr = 1<<8,
94 LLVMReadNoneParamAttr = 1<<9,
95 LLVMReadOnlyParamAttr = 1<<10
96 } LLVMParamAttr;
8397
8498 typedef enum {
8599 LLVMVoidTypeKind, /**< type with no size */
412426 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
413427 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
414428 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
429 void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA);
430 void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA);
431 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
415432
416433 /* Operations on basic blocks */
417434 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
440457 /* Operations on call sites */
441458 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
442459 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
460 void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index, LLVMParamAttr);
461 void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index,
462 LLVMParamAttr);
463 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
464 unsigned align);
443465
444466 /* Operations on phi nodes */
445467 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
1919 #include "llvm/TypeSymbolTable.h"
2020 #include "llvm/ModuleProvider.h"
2121 #include "llvm/Support/MemoryBuffer.h"
22 #include "llvm/Support/CallSite.h"
2223 #include
2324 #include
2425 #include
797798 return wrap(--I);
798799 }
799800
801 void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) {
802 unwrap(Arg)->addAttr(PA);
803 }
804
805 void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) {
806 unwrap(Arg)->removeAttr(PA);
807 }
808
809 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
810 unwrap(Arg)->addAttr(
811 ParamAttr::constructAlignmentFromInt(align));
812 }
813
800814 /*--.. Operations on basic blocks ..........................................--*/
801815
802816 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) {
935949 assert(0 && "LLVMSetInstructionCallConv applies only to call and invoke!");
936950 }
937951
952 void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index,
953 LLVMParamAttr PA) {
954 CallSite Call = CallSite(unwrap(Instr));
955 Call.setParamAttrs(
956 Call.getParamAttrs().addAttr(index, PA));
957 }
958
959 void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index,
960 LLVMParamAttr PA) {
961 CallSite Call = CallSite(unwrap(Instr));
962 Call.setParamAttrs(
963 Call.getParamAttrs().removeAttr(index, PA));
964 }
965
966 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
967 unsigned align) {
968 CallSite Call = CallSite(unwrap(Instr));
969 Call.setParamAttrs(
970 Call.getParamAttrs().addAttr(index,
971 ParamAttr::constructAlignmentFromInt(align)));
972 }
973
938974 /*--.. Operations on phi nodes .............................................--*/
939975
940976 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
109109 return getParent()->paramHasAttr(1, ParamAttr::StructRet);
110110 }
111111
112 /// addAttr - Add a ParamAttr to an argument
113 void Argument::addAttr(ParameterAttributes attr) {
114 getParent()->setParamAttrs(
115 getParent()->getParamAttrs().addAttr(getArgNo() + 1, attr));
116 }
117
118 /// removeAttr - Remove a ParamAttr from an argument
119 void Argument::removeAttr(ParameterAttributes attr) {
120 getParent()->setParamAttrs(
121 getParent()->getParamAttrs().removeAttr(getArgNo() + 1, attr));
122 }
112123
113124
114125