#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
-#include "llvm/GlobalVariable.h"
#include "llvm/GlobalAlias.h"
-#include "llvm/LLVMContext.h"
+#include "llvm/GlobalVariable.h"
#include "llvm/InlineAsm.h"
#include "llvm/IntrinsicInst.h"
+#include "llvm/LLVMContext.h"
#include "llvm/PassManager.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Debug.h"
void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn);
- const AttrListPtr PAL = Func->getAttributes();
- Attributes::Builder B(PA);
- const AttrListPtr PALnew =
- PAL.addAttr(Func->getContext(), AttrListPtr::FunctionIndex,
- Attributes::get(Func->getContext(), B));
+ const AttributeSet PAL = Func->getAttributes();
+ AttrBuilder B(PA);
+ const AttributeSet PALnew =
+ PAL.addAttr(Func->getContext(), AttributeSet::FunctionIndex,
+ Attribute::get(Func->getContext(), B));
Func->setAttributes(PALnew);
}
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn);
- const AttrListPtr PAL = Func->getAttributes();
- Attributes::Builder B(PA);
- const AttrListPtr PALnew =
- PAL.removeAttr(Func->getContext(), AttrListPtr::FunctionIndex,
- Attributes::get(Func->getContext(), B));
+ const AttributeSet PAL = Func->getAttributes();
+ AttrBuilder B(PA);
+ const AttributeSet PALnew =
+ PAL.removeAttr(Func->getContext(), AttributeSet::FunctionIndex,
+ Attribute::get(Func->getContext(), B));
Func->setAttributes(PALnew);
}
LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn) {
Function *Func = unwrap<Function>(Fn);
- const AttrListPtr PAL = Func->getAttributes();
- Attributes attr = PAL.getFnAttributes();
- return (LLVMAttribute)attr.Raw();
+ const AttributeSet PAL = Func->getAttributes();
+ return (LLVMAttribute)PAL.getBitMask(AttributeSet::FunctionIndex);
}
/*--.. Operations on parameters ............................................--*/
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
Argument *A = unwrap<Argument>(Arg);
- Attributes::Builder B(PA);
- A->addAttr(Attributes::get(A->getContext(), B));
+ AttrBuilder B(PA);
+ A->addAttr(Attribute::get(A->getContext(), B));
}
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
Argument *A = unwrap<Argument>(Arg);
- Attributes::Builder B(PA);
- A->removeAttr(Attributes::get(A->getContext(), B));
+ AttrBuilder B(PA);
+ A->removeAttr(Attribute::get(A->getContext(), B));
}
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
Argument *A = unwrap<Argument>(Arg);
- Attributes attr = A->getParent()->getAttributes().getParamAttributes(
+ Attribute attr = A->getParent()->getAttributes().getParamAttributes(
A->getArgNo()+1);
- return (LLVMAttribute)attr.Raw();
+ return (LLVMAttribute)attr.getBitMask();
}
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
- Attributes::Builder B;
+ AttrBuilder B;
B.addAlignmentAttr(align);
- unwrap<Argument>(Arg)->addAttr(Attributes::
+ unwrap<Argument>(Arg)->addAttr(Attribute::
get(unwrap<Argument>(Arg)->getContext(), B));
}
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
- Attributes::Builder B(PA);
+ AttrBuilder B(PA);
Call.setAttributes(
Call.getAttributes().addAttr(Call->getContext(), index,
- Attributes::get(Call->getContext(), B)));
+ Attribute::get(Call->getContext(), B)));
}
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
- Attributes::Builder B(PA);
+ AttrBuilder B(PA);
Call.setAttributes(
Call.getAttributes().removeAttr(Call->getContext(), index,
- Attributes::get(Call->getContext(), B)));
+ Attribute::get(Call->getContext(), B)));
}
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
unsigned align) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
- Attributes::Builder B;
+ AttrBuilder B;
B.addAlignmentAttr(align);
Call.setAttributes(Call.getAttributes().addAttr(Call->getContext(), index,
- Attributes::get(Call->getContext(), B)));
+ Attribute::get(Call->getContext(), B)));
}
/*--.. Operations on call instructions (only) ..............................--*/