diff options
Diffstat (limited to 'lib/VMCore/Core.cpp')
-rw-r--r-- | lib/VMCore/Core.cpp | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index 972db3c..847bc13 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -568,6 +568,19 @@ const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len) { return 0; } +unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V) +{ + return cast<MDNode>(unwrap(V))->getNumOperands(); +} + +void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest) +{ + const MDNode *N = cast<MDNode>(unwrap(V)); + const unsigned numOperands = N->getNumOperands(); + for (unsigned i = 0; i < numOperands; i++) + Dest[i] = wrap(N->getOperand(i)); +} + unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name) { if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) { @@ -1084,6 +1097,8 @@ LLVMLinkage LLVMGetLinkage(LLVMValueRef Global) { return LLVMLinkOnceAnyLinkage; case GlobalValue::LinkOnceODRLinkage: return LLVMLinkOnceODRLinkage; + case GlobalValue::LinkOnceODRAutoHideLinkage: + return LLVMLinkOnceODRAutoHideLinkage; case GlobalValue::WeakAnyLinkage: return LLVMWeakAnyLinkage; case GlobalValue::WeakODRLinkage: @@ -1098,8 +1113,6 @@ LLVMLinkage LLVMGetLinkage(LLVMValueRef Global) { return LLVMLinkerPrivateLinkage; case GlobalValue::LinkerPrivateWeakLinkage: return LLVMLinkerPrivateWeakLinkage; - case GlobalValue::LinkerPrivateWeakDefAutoLinkage: - return LLVMLinkerPrivateWeakDefAutoLinkage; case GlobalValue::DLLImportLinkage: return LLVMDLLImportLinkage; case GlobalValue::DLLExportLinkage: @@ -1129,6 +1142,9 @@ void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage) { case LLVMLinkOnceODRLinkage: GV->setLinkage(GlobalValue::LinkOnceODRLinkage); break; + case LLVMLinkOnceODRAutoHideLinkage: + GV->setLinkage(GlobalValue::LinkOnceODRAutoHideLinkage); + break; case LLVMWeakAnyLinkage: GV->setLinkage(GlobalValue::WeakAnyLinkage); break; @@ -1150,9 +1166,6 @@ void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage) { case LLVMLinkerPrivateWeakLinkage: GV->setLinkage(GlobalValue::LinkerPrivateWeakLinkage); break; - case LLVMLinkerPrivateWeakDefAutoLinkage: - GV->setLinkage(GlobalValue::LinkerPrivateWeakDefAutoLinkage); - break; case LLVMDLLImportLinkage: GV->setLinkage(GlobalValue::DLLImportLinkage); break; @@ -1368,14 +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(~0U, Attributes(PA)); + AttrBuilder B(PA); + const AttrListPtr PALnew = + PAL.addAttr(Func->getContext(), AttrListPtr::FunctionIndex, + 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(~0U, Attributes(PA)); + AttrBuilder B(PA); + const AttrListPtr PALnew = + PAL.removeAttr(Func->getContext(), AttrListPtr::FunctionIndex, + Attributes::get(Func->getContext(), B)); Func->setAttributes(PALnew); } @@ -1445,11 +1464,15 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) { } void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) { - unwrap<Argument>(Arg)->addAttr(Attributes(PA)); + Argument *A = unwrap<Argument>(Arg); + AttrBuilder 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); + AttrBuilder B(PA); + A->removeAttr(Attributes::get(A->getContext(), B)); } LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) { @@ -1461,8 +1484,10 @@ LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) { void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) { - unwrap<Argument>(Arg)->addAttr( - Attribute::constructAlignmentFromInt(align)); + AttrBuilder B; + B.addAlignmentAttr(align); + unwrap<Argument>(Arg)->addAttr(Attributes:: + get(unwrap<Argument>(Arg)->getContext(), B)); } /*--.. Operations on basic blocks ..........................................--*/ @@ -1651,23 +1676,28 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) { void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute PA) { CallSite Call = CallSite(unwrap<Instruction>(Instr)); + AttrBuilder B(PA); Call.setAttributes( - Call.getAttributes().addAttr(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)); + AttrBuilder B(PA); Call.setAttributes( - Call.getAttributes().removeAttr(index, Attributes(PA))); + Call.getAttributes().removeAttr(Call->getContext(), index, + Attributes::get(Call->getContext(), B))); } void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, unsigned align) { CallSite Call = CallSite(unwrap<Instruction>(Instr)); - Call.setAttributes( - Call.getAttributes().addAttr(index, - Attribute::constructAlignmentFromInt(align))); + AttrBuilder B; + B.addAlignmentAttr(align); + Call.setAttributes(Call.getAttributes().addAttr(Call->getContext(), index, + Attributes::get(Call->getContext(), B))); } /*--.. Operations on call instructions (only) ..............................--*/ |