summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Attributes.cpp14
-rw-r--r--llvm/lib/IR/Core.cpp24
-rw-r--r--llvm/lib/IR/Function.cpp6
-rw-r--r--llvm/lib/IR/Instructions.cpp20
4 files changed, 63 insertions, 1 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 3675bad2fb0..b470fac5782 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -807,6 +807,14 @@ AttributeSet AttributeSet::get(LLVMContext &C, unsigned Index,
return get(C, Attrs);
}
+AttributeSet AttributeSet::get(LLVMContext &C, unsigned Index,
+ ArrayRef<StringRef> Kinds) {
+ SmallVector<std::pair<unsigned, Attribute>, 8> Attrs;
+ for (StringRef K : Kinds)
+ Attrs.push_back(std::make_pair(Index, Attribute::get(C, K)));
+ return get(C, Attrs);
+}
+
AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef<AttributeSet> Attrs) {
if (Attrs.empty()) return AttributeSet();
if (Attrs.size() == 1) return Attrs[0];
@@ -935,6 +943,12 @@ AttributeSet AttributeSet::removeAttribute(LLVMContext &C, unsigned Index,
return removeAttributes(C, Index, AttributeSet::get(C, Index, Kind));
}
+AttributeSet AttributeSet::removeAttribute(LLVMContext &C, unsigned Index,
+ StringRef Kind) const {
+ if (!hasAttribute(Index, Kind)) return *this;
+ return removeAttributes(C, Index, AttributeSet::get(C, Index, Kind));
+}
+
AttributeSet AttributeSet::removeAttributes(LLVMContext &C, unsigned Index,
AttributeSet Attrs) const {
if (!pImpl) return AttributeSet();
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index c965063d8c7..a1c094a758c 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -209,7 +209,6 @@ LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI) {
return severity;
}
-
/*===-- Operations on modules ---------------------------------------------===*/
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID) {
@@ -1852,11 +1851,22 @@ LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
(Attribute::AttrKind)KindID));
}
+LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
+ LLVMAttributeIndex Idx,
+ const char *K, unsigned KLen) {
+ return wrap(unwrap<Function>(F)->getAttribute(Idx, StringRef(K, KLen)));
+}
+
void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
unsigned KindID) {
unwrap<Function>(F)->removeAttribute(Idx, (Attribute::AttrKind)KindID);
}
+void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
+ const char *K, unsigned KLen) {
+ unwrap<Function>(F)->removeAttribute(Idx, StringRef(K, KLen));
+}
+
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
const char *V) {
Function *Func = unwrap<Function>(Fn);
@@ -2213,12 +2223,24 @@ LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
.getAttribute(Idx, (Attribute::AttrKind)KindID));
}
+LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
+ LLVMAttributeIndex Idx,
+ const char *K, unsigned KLen) {
+ return wrap(CallSite(unwrap<Instruction>(C))
+ .getAttribute(Idx, StringRef(K, KLen)));
+}
+
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
unsigned KindID) {
CallSite(unwrap<Instruction>(C))
.removeAttribute(Idx, (Attribute::AttrKind)KindID);
}
+void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
+ const char *K, unsigned KLen) {
+ CallSite(unwrap<Instruction>(C)).removeAttribute(Idx, StringRef(K, KLen));
+}
+
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr) {
return wrap(CallSite(unwrap<Instruction>(Instr)).getCalledValue());
}
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index b71e1baf1e9..07b21151e60 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -390,6 +390,12 @@ void Function::removeAttribute(unsigned i, Attribute::AttrKind Kind) {
setAttributes(PAL);
}
+void Function::removeAttribute(unsigned i, StringRef Kind) {
+ AttributeSet PAL = getAttributes();
+ PAL = PAL.removeAttribute(getContext(), i, Kind);
+ setAttributes(PAL);
+}
+
void Function::removeAttributes(unsigned i, AttributeSet Attrs) {
AttributeSet PAL = getAttributes();
PAL = PAL.removeAttributes(getContext(), i, Attrs);
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 98d37074b4a..6f60d15c52c 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -355,6 +355,12 @@ void CallInst::removeAttribute(unsigned i, Attribute::AttrKind Kind) {
setAttributes(PAL);
}
+void CallInst::removeAttribute(unsigned i, StringRef Kind) {
+ AttributeSet PAL = getAttributes();
+ PAL = PAL.removeAttribute(getContext(), i, Kind);
+ setAttributes(PAL);
+}
+
void CallInst::removeAttribute(unsigned i, Attribute Attr) {
AttributeSet PAL = getAttributes();
AttrBuilder B(Attr);
@@ -390,6 +396,10 @@ Attribute CallInst::getAttribute(unsigned i, Attribute::AttrKind Kind) const {
return getAttributes().getAttribute(i, Kind);
}
+Attribute CallInst::getAttribute(unsigned i, StringRef Kind) const {
+ return getAttributes().getAttribute(i, Kind);
+}
+
bool CallInst::dataOperandHasImpliedAttr(unsigned i,
Attribute::AttrKind Kind) const {
// There are getNumOperands() - 1 data operands. The last operand is the
@@ -724,6 +734,12 @@ void InvokeInst::removeAttribute(unsigned i, Attribute::AttrKind Kind) {
setAttributes(PAL);
}
+void InvokeInst::removeAttribute(unsigned i, StringRef Kind) {
+ AttributeSet PAL = getAttributes();
+ PAL = PAL.removeAttribute(getContext(), i, Kind);
+ setAttributes(PAL);
+}
+
void InvokeInst::removeAttribute(unsigned i, Attribute Attr) {
AttributeSet PAL = getAttributes();
AttrBuilder B(Attr);
@@ -737,6 +753,10 @@ Attribute InvokeInst::getAttribute(unsigned i,
return getAttributes().getAttribute(i, Kind);
}
+Attribute InvokeInst::getAttribute(unsigned i, StringRef Kind) const {
+ return getAttributes().getAttribute(i, Kind);
+}
+
void InvokeInst::addDereferenceableAttr(unsigned i, uint64_t Bytes) {
AttributeSet PAL = getAttributes();
PAL = PAL.addDereferenceableAttr(getContext(), i, Bytes);
OpenPOWER on IntegriCloud