aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Core.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-10-15 04:46:55 +0000
committerBill Wendling <isanbard@gmail.com>2012-10-15 04:46:55 +0000
commitcb3de0bc800d7920087b19bb12a545d4cc84114e (patch)
treecbd5a447bcc1d11449532b3c92119f26eeb5a815 /lib/VMCore/Core.cpp
parenta239c2e6a7775e890bcfb0867b84e512ceb993de (diff)
Attributes Rewrite
Convert the internal representation of the Attributes class into a pointer to an opaque object that's uniqued by and stored in the LLVMContext object. The Attributes class then becomes a thin wrapper around this opaque object. Eventually, the internal representation will be expanded to include attributes that represent code generation options, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165917 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Core.cpp')
-rw-r--r--lib/VMCore/Core.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index c6da24be93..6643ad6e9a 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -1381,16 +1381,20 @@ void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn);
const AttrListPtr PAL = Func->getAttributes();
- const AttrListPtr PALnew = PAL.addAttr(Func->getContext(), ~0U,
- Attributes(PA));
+ Attributes::Builder B(PA);
+ const AttrListPtr PALnew =
+ PAL.addAttr(Func->getContext(), ~0U,
+ Attributes::get(Func->getContext(), B));
Func->setAttributes(PALnew);
}
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn);
const AttrListPtr PAL = Func->getAttributes();
- const AttrListPtr PALnew = PAL.removeAttr(Func->getContext(), ~0U,
- Attributes(PA));
+ Attributes::Builder B(PA);
+ const AttrListPtr PALnew =
+ PAL.removeAttr(Func->getContext(), ~0U,
+ Attributes::get(Func->getContext(), B));
Func->setAttributes(PALnew);
}
@@ -1460,11 +1464,15 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) {
}
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
- unwrap<Argument>(Arg)->addAttr(Attributes(PA));
+ Argument *A = unwrap<Argument>(Arg);
+ Attributes::Builder B(PA);
+ A->addAttr(Attributes::get(A->getContext(), B));
}
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
- unwrap<Argument>(Arg)->removeAttr(Attributes(PA));
+ Argument *A = unwrap<Argument>(Arg);
+ Attributes::Builder B(PA);
+ A->removeAttr(Attributes::get(A->getContext(), B));
}
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
@@ -1478,7 +1486,8 @@ LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
Attributes::Builder B;
B.addAlignmentAttr(align);
- unwrap<Argument>(Arg)->addAttr(Attributes::get(B));
+ unwrap<Argument>(Arg)->addAttr(Attributes::
+ get(unwrap<Argument>(Arg)->getContext(), B));
}
/*--.. Operations on basic blocks ..........................................--*/
@@ -1667,15 +1676,19 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
+ Attributes::Builder B(PA);
Call.setAttributes(
- Call.getAttributes().addAttr(Call->getContext(), index, Attributes(PA)));
+ Call.getAttributes().addAttr(Call->getContext(), index,
+ Attributes::get(Call->getContext(), B)));
}
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
+ Attributes::Builder B(PA);
Call.setAttributes(
- Call.getAttributes().removeAttr(Call->getContext(), index, Attributes(PA)));
+ Call.getAttributes().removeAttr(Call->getContext(), index,
+ Attributes::get(Call->getContext(), B)));
}
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
@@ -1684,7 +1697,7 @@ void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Attributes::Builder B;
B.addAlignmentAttr(align);
Call.setAttributes(Call.getAttributes().addAttr(Call->getContext(), index,
- Attributes::get(B)));
+ Attributes::get(Call->getContext(), B)));
}
/*--.. Operations on call instructions (only) ..............................--*/