mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Add some convenience methods for manipulating
call attributes. llvm-svn: 53223
This commit is contained in:
parent
d4bcc9011b
commit
b854603cb5
@ -1065,6 +1065,9 @@ public:
|
|||||||
/// addParamAttr - adds the attribute to the list of attributes.
|
/// addParamAttr - adds the attribute to the list of attributes.
|
||||||
void addParamAttr(unsigned i, ParameterAttributes attr);
|
void addParamAttr(unsigned i, ParameterAttributes attr);
|
||||||
|
|
||||||
|
/// removeParamAttr - removes the attribute from the list of attributes.
|
||||||
|
void removeParamAttr(unsigned i, ParameterAttributes attr);
|
||||||
|
|
||||||
/// @brief Determine whether the call or the callee has the given attribute.
|
/// @brief Determine whether the call or the callee has the given attribute.
|
||||||
bool paramHasAttr(unsigned i, unsigned attr) const;
|
bool paramHasAttr(unsigned i, unsigned attr) const;
|
||||||
|
|
||||||
@ -1077,22 +1080,37 @@ public:
|
|||||||
bool doesNotAccessMemory() const {
|
bool doesNotAccessMemory() const {
|
||||||
return paramHasAttr(0, ParamAttr::ReadNone);
|
return paramHasAttr(0, ParamAttr::ReadNone);
|
||||||
}
|
}
|
||||||
|
void setDoesNotAccessMemory(bool doesNotAccessMemory = true) {
|
||||||
|
if (doesNotAccessMemory) addParamAttr(0, ParamAttr::ReadNone);
|
||||||
|
else removeParamAttr(0, ParamAttr::ReadNone);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access or only reads memory.
|
/// @brief Determine if the call does not access or only reads memory.
|
||||||
bool onlyReadsMemory() const {
|
bool onlyReadsMemory() const {
|
||||||
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
|
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
|
||||||
}
|
}
|
||||||
|
void setOnlyReadsMemory(bool onlyReadsMemory = true) {
|
||||||
|
if (onlyReadsMemory) addParamAttr(0, ParamAttr::ReadOnly);
|
||||||
|
else removeParamAttr(0, ParamAttr::ReadOnly | ParamAttr::ReadNone);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot return.
|
/// @brief Determine if the call cannot return.
|
||||||
bool doesNotReturn() const {
|
bool doesNotReturn() const {
|
||||||
return paramHasAttr(0, ParamAttr::NoReturn);
|
return paramHasAttr(0, ParamAttr::NoReturn);
|
||||||
}
|
}
|
||||||
|
void setDoesNotReturn(bool doesNotReturn = true) {
|
||||||
|
if (doesNotReturn) addParamAttr(0, ParamAttr::NoReturn);
|
||||||
|
else removeParamAttr(0, ParamAttr::NoReturn);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot unwind.
|
/// @brief Determine if the call cannot unwind.
|
||||||
bool doesNotThrow() const {
|
bool doesNotThrow() const {
|
||||||
return paramHasAttr(0, ParamAttr::NoUnwind);
|
return paramHasAttr(0, ParamAttr::NoUnwind);
|
||||||
}
|
}
|
||||||
void setDoesNotThrow(bool doesNotThrow = true);
|
void setDoesNotThrow(bool doesNotThrow = true) {
|
||||||
|
if (doesNotThrow) addParamAttr(0, ParamAttr::NoUnwind);
|
||||||
|
else removeParamAttr(0, ParamAttr::NoUnwind);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call returns a structure through first
|
/// @brief Determine if the call returns a structure through first
|
||||||
/// pointer argument.
|
/// pointer argument.
|
||||||
@ -2427,6 +2445,9 @@ public:
|
|||||||
/// addParamAttr - adds the attribute to the list of attributes.
|
/// addParamAttr - adds the attribute to the list of attributes.
|
||||||
void addParamAttr(unsigned i, ParameterAttributes attr);
|
void addParamAttr(unsigned i, ParameterAttributes attr);
|
||||||
|
|
||||||
|
/// removeParamAttr - removes the attribute from the list of attributes.
|
||||||
|
void removeParamAttr(unsigned i, ParameterAttributes attr);
|
||||||
|
|
||||||
/// @brief Extract the alignment for a call or parameter (0=unknown).
|
/// @brief Extract the alignment for a call or parameter (0=unknown).
|
||||||
unsigned getParamAlignment(unsigned i) const {
|
unsigned getParamAlignment(unsigned i) const {
|
||||||
return ParamAttrs.getParamAlignment(i);
|
return ParamAttrs.getParamAlignment(i);
|
||||||
@ -2436,22 +2457,37 @@ public:
|
|||||||
bool doesNotAccessMemory() const {
|
bool doesNotAccessMemory() const {
|
||||||
return paramHasAttr(0, ParamAttr::ReadNone);
|
return paramHasAttr(0, ParamAttr::ReadNone);
|
||||||
}
|
}
|
||||||
|
void setDoesNotAccessMemory(bool doesNotAccessMemory = true) {
|
||||||
|
if (doesNotAccessMemory) addParamAttr(0, ParamAttr::ReadNone);
|
||||||
|
else removeParamAttr(0, ParamAttr::ReadNone);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access or only reads memory.
|
/// @brief Determine if the call does not access or only reads memory.
|
||||||
bool onlyReadsMemory() const {
|
bool onlyReadsMemory() const {
|
||||||
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
|
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
|
||||||
}
|
}
|
||||||
|
void setOnlyReadsMemory(bool onlyReadsMemory = true) {
|
||||||
|
if (onlyReadsMemory) addParamAttr(0, ParamAttr::ReadOnly);
|
||||||
|
else removeParamAttr(0, ParamAttr::ReadOnly | ParamAttr::ReadNone);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot return.
|
/// @brief Determine if the call cannot return.
|
||||||
bool doesNotReturn() const {
|
bool doesNotReturn() const {
|
||||||
return paramHasAttr(0, ParamAttr::NoReturn);
|
return paramHasAttr(0, ParamAttr::NoReturn);
|
||||||
}
|
}
|
||||||
|
void setDoesNotReturn(bool doesNotReturn = true) {
|
||||||
|
if (doesNotReturn) addParamAttr(0, ParamAttr::NoReturn);
|
||||||
|
else removeParamAttr(0, ParamAttr::NoReturn);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot unwind.
|
/// @brief Determine if the call cannot unwind.
|
||||||
bool doesNotThrow() const {
|
bool doesNotThrow() const {
|
||||||
return paramHasAttr(0, ParamAttr::NoUnwind);
|
return paramHasAttr(0, ParamAttr::NoUnwind);
|
||||||
}
|
}
|
||||||
void setDoesNotThrow(bool doesNotThrow = true);
|
void setDoesNotThrow(bool doesNotThrow = true) {
|
||||||
|
if (doesNotThrow) addParamAttr(0, ParamAttr::NoUnwind);
|
||||||
|
else removeParamAttr(0, ParamAttr::NoUnwind);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call returns a structure through first
|
/// @brief Determine if the call returns a structure through first
|
||||||
/// pointer argument.
|
/// pointer argument.
|
||||||
|
@ -75,9 +75,15 @@ public:
|
|||||||
|
|
||||||
/// @brief Determine if the call does not access memory.
|
/// @brief Determine if the call does not access memory.
|
||||||
bool doesNotAccessMemory() const;
|
bool doesNotAccessMemory() const;
|
||||||
|
void setDoesNotAccessMemory(bool doesNotAccessMemory = true);
|
||||||
|
|
||||||
/// @brief Determine if the call does not access or only reads memory.
|
/// @brief Determine if the call does not access or only reads memory.
|
||||||
bool onlyReadsMemory() const;
|
bool onlyReadsMemory() const;
|
||||||
|
void setOnlyReadsMemory(bool onlyReadsMemory = true);
|
||||||
|
|
||||||
|
/// @brief Determine if the call cannot return.
|
||||||
|
bool doesNotReturn() const;
|
||||||
|
void setDoesNotReturn(bool doesNotReturn = true);
|
||||||
|
|
||||||
/// @brief Determine if the call cannot unwind.
|
/// @brief Determine if the call cannot unwind.
|
||||||
bool doesNotThrow() const;
|
bool doesNotThrow() const;
|
||||||
|
@ -72,12 +72,36 @@ bool CallSite::doesNotAccessMemory() const {
|
|||||||
else
|
else
|
||||||
return cast<InvokeInst>(I)->doesNotAccessMemory();
|
return cast<InvokeInst>(I)->doesNotAccessMemory();
|
||||||
}
|
}
|
||||||
|
void CallSite::setDoesNotAccessMemory(bool doesNotAccessMemory) {
|
||||||
|
if (CallInst *CI = dyn_cast<CallInst>(I))
|
||||||
|
CI->setDoesNotAccessMemory(doesNotAccessMemory);
|
||||||
|
else
|
||||||
|
cast<InvokeInst>(I)->setDoesNotAccessMemory(doesNotAccessMemory);
|
||||||
|
}
|
||||||
bool CallSite::onlyReadsMemory() const {
|
bool CallSite::onlyReadsMemory() const {
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(I))
|
if (CallInst *CI = dyn_cast<CallInst>(I))
|
||||||
return CI->onlyReadsMemory();
|
return CI->onlyReadsMemory();
|
||||||
else
|
else
|
||||||
return cast<InvokeInst>(I)->onlyReadsMemory();
|
return cast<InvokeInst>(I)->onlyReadsMemory();
|
||||||
}
|
}
|
||||||
|
void CallSite::setOnlyReadsMemory(bool onlyReadsMemory) {
|
||||||
|
if (CallInst *CI = dyn_cast<CallInst>(I))
|
||||||
|
CI->setOnlyReadsMemory(onlyReadsMemory);
|
||||||
|
else
|
||||||
|
cast<InvokeInst>(I)->setOnlyReadsMemory(onlyReadsMemory);
|
||||||
|
}
|
||||||
|
bool CallSite::doesNotReturn() const {
|
||||||
|
if (CallInst *CI = dyn_cast<CallInst>(I))
|
||||||
|
return CI->doesNotReturn();
|
||||||
|
else
|
||||||
|
return cast<InvokeInst>(I)->doesNotReturn();
|
||||||
|
}
|
||||||
|
void CallSite::setDoesNotReturn(bool doesNotReturn) {
|
||||||
|
if (CallInst *CI = dyn_cast<CallInst>(I))
|
||||||
|
CI->setDoesNotReturn(doesNotReturn);
|
||||||
|
else
|
||||||
|
cast<InvokeInst>(I)->setDoesNotReturn(doesNotReturn);
|
||||||
|
}
|
||||||
bool CallSite::doesNotThrow() const {
|
bool CallSite::doesNotThrow() const {
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(I))
|
if (CallInst *CI = dyn_cast<CallInst>(I))
|
||||||
return CI->doesNotThrow();
|
return CI->doesNotThrow();
|
||||||
@ -384,6 +408,12 @@ void CallInst::addParamAttr(unsigned i, ParameterAttributes attr) {
|
|||||||
setParamAttrs(PAL);
|
setParamAttrs(PAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CallInst::removeParamAttr(unsigned i, ParameterAttributes attr) {
|
||||||
|
PAListPtr PAL = getParamAttrs();
|
||||||
|
PAL = PAL.removeAttr(i, attr);
|
||||||
|
setParamAttrs(PAL);
|
||||||
|
}
|
||||||
|
|
||||||
bool CallInst::paramHasAttr(unsigned i, ParameterAttributes attr) const {
|
bool CallInst::paramHasAttr(unsigned i, ParameterAttributes attr) const {
|
||||||
if (ParamAttrs.paramHasAttr(i, attr))
|
if (ParamAttrs.paramHasAttr(i, attr))
|
||||||
return true;
|
return true;
|
||||||
@ -392,15 +422,6 @@ bool CallInst::paramHasAttr(unsigned i, ParameterAttributes attr) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallInst::setDoesNotThrow(bool doesNotThrow) {
|
|
||||||
PAListPtr PAL = getParamAttrs();
|
|
||||||
if (doesNotThrow)
|
|
||||||
PAL = PAL.addAttr(0, ParamAttr::NoUnwind);
|
|
||||||
else
|
|
||||||
PAL = PAL.removeAttr(0, ParamAttr::NoUnwind);
|
|
||||||
setParamAttrs(PAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// InvokeInst Implementation
|
// InvokeInst Implementation
|
||||||
@ -466,12 +487,9 @@ void InvokeInst::addParamAttr(unsigned i, ParameterAttributes attr) {
|
|||||||
setParamAttrs(PAL);
|
setParamAttrs(PAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InvokeInst::setDoesNotThrow(bool doesNotThrow) {
|
void InvokeInst::removeParamAttr(unsigned i, ParameterAttributes attr) {
|
||||||
PAListPtr PAL = getParamAttrs();
|
PAListPtr PAL = getParamAttrs();
|
||||||
if (doesNotThrow)
|
PAL = PAL.removeAttr(i, attr);
|
||||||
PAL = PAL.addAttr(0, ParamAttr::NoUnwind);
|
|
||||||
else
|
|
||||||
PAL = PAL.removeAttr(0, ParamAttr::NoUnwind);
|
|
||||||
setParamAttrs(PAL);
|
setParamAttrs(PAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user