aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-04-09 15:01:12 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-04-09 15:01:12 +0000
commit4746ecf16eeb5ff920672fdff1c0dd85594437ed (patch)
tree3325b29641ff0704e69a93a2994446de651e4ea4 /lib/VMCore
parentefc366263659db05ddc5e14532946cb9213bcdd6 (diff)
downloadexternal_llvm-4746ecf16eeb5ff920672fdff1c0dd85594437ed.zip
external_llvm-4746ecf16eeb5ff920672fdff1c0dd85594437ed.tar.gz
external_llvm-4746ecf16eeb5ff920672fdff1c0dd85594437ed.tar.bz2
For PR1146:
* Add ParamAttrList pointers to Function and CallInst. * Move the implementation of ParamAttrList from Type.cpp to Function.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Function.cpp64
-rw-r--r--lib/VMCore/Instructions.cpp4
-rw-r--r--lib/VMCore/Type.cpp59
3 files changed, 68 insertions, 59 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 5da3ceb..c6bf331 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -72,12 +72,76 @@ void Argument::setParent(Function *parent) {
}
//===----------------------------------------------------------------------===//
+// ParamAttrsList Implementation
+//===----------------------------------------------------------------------===//
+
+uint16_t
+ParamAttrsList::getParamAttrs(uint16_t Index) const {
+ unsigned limit = attrs.size();
+ for (unsigned i = 0; i < limit; ++i)
+ if (attrs[i].index == Index)
+ return attrs[i].attrs;
+ return NoAttributeSet;
+}
+
+
+std::string
+ParamAttrsList::getParamAttrsText(uint16_t Attrs) {
+ std::string Result;
+ if (Attrs & ZExtAttribute)
+ Result += "zext ";
+ if (Attrs & SExtAttribute)
+ Result += "sext ";
+ if (Attrs & NoReturnAttribute)
+ Result += "noreturn ";
+ if (Attrs & NoUnwindAttribute)
+ Result += "nounwind ";
+ if (Attrs & InRegAttribute)
+ Result += "inreg ";
+ if (Attrs & StructRetAttribute)
+ Result += "sret ";
+ return Result;
+}
+
+void
+ParamAttrsList::addAttributes(uint16_t Index, uint16_t Attrs) {
+ // First, try to replace an existing one
+ for (unsigned i = 0; i < attrs.size(); ++i)
+ if (attrs[i].index == Index) {
+ attrs[i].attrs |= Attrs;
+ return;
+ }
+
+ // If not found, add a new one
+ ParamAttrsWithIndex Val;
+ Val.attrs = Attrs;
+ Val.index = Index;
+ attrs.push_back(Val);
+}
+
+void
+ParamAttrsList::removeAttributes(uint16_t Index, uint16_t Attrs) {
+ // Find the index from which to remove the attributes
+ for (unsigned i = 0; i < attrs.size(); ++i)
+ if (attrs[i].index == Index) {
+ attrs[i].attrs &= ~Attrs;
+ if (attrs[i].attrs == NoAttributeSet)
+ attrs.erase(&attrs[i]);
+ return;
+ }
+
+ // The index wasn't found above
+ assert(0 && "Index not found for removeAttributes");
+}
+
+//===----------------------------------------------------------------------===//
// Function Implementation
//===----------------------------------------------------------------------===//
Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
const std::string &name, Module *ParentModule)
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, 0, 0, Linkage, name) {
+ ParamAttrs = 0;
CallingConvention = 0;
BasicBlocks.setItemParent(this);
BasicBlocks.setParent(this);
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index c7da56b..c09ec3c 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -188,6 +188,7 @@ CallInst::~CallInst() {
}
void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
+ ParamAttrs = 0;
NumOperands = NumParams+1;
Use *OL = OperandList = new Use[NumParams+1];
OL[0].init(Func, this);
@@ -208,6 +209,7 @@ void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
}
void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
+ ParamAttrs = 0;
NumOperands = 3;
Use *OL = OperandList = new Use[3];
OL[0].init(Func, this);
@@ -230,6 +232,7 @@ void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
}
void CallInst::init(Value *Func, Value *Actual) {
+ ParamAttrs = 0;
NumOperands = 2;
Use *OL = OperandList = new Use[2];
OL[0].init(Func, this);
@@ -248,6 +251,7 @@ void CallInst::init(Value *Func, Value *Actual) {
}
void CallInst::init(Value *Func) {
+ ParamAttrs = 0;
NumOperands = 1;
Use *OL = OperandList = new Use[1];
OL[0].init(Func, this);
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 40bcdb2..0e74f2e 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -1121,65 +1121,6 @@ bool FunctionType::isStructReturn() const {
return false;
}
-uint16_t
-ParamAttrsList::getParamAttrs(uint16_t Index) const {
- unsigned limit = attrs.size();
- for (unsigned i = 0; i < limit; ++i)
- if (attrs[i].index == Index)
- return attrs[i].attrs;
- return NoAttributeSet;
-}
-
-
-std::string
-ParamAttrsList::getParamAttrsText(uint16_t Attrs) {
- std::string Result;
- if (Attrs & ZExtAttribute)
- Result += "zext ";
- if (Attrs & SExtAttribute)
- Result += "sext ";
- if (Attrs & NoReturnAttribute)
- Result += "noreturn ";
- if (Attrs & NoUnwindAttribute)
- Result += "nounwind ";
- if (Attrs & InRegAttribute)
- Result += "inreg ";
- if (Attrs & StructRetAttribute)
- Result += "sret ";
- return Result;
-}
-
-void
-ParamAttrsList::addAttributes(uint16_t Index, uint16_t Attrs) {
- // First, try to replace an existing one
- for (unsigned i = 0; i < attrs.size(); ++i)
- if (attrs[i].index == Index) {
- attrs[i].attrs |= Attrs;
- return;
- }
-
- // If not found, add a new one
- ParamAttrsWithIndex Val;
- Val.attrs = Attrs;
- Val.index = Index;
- attrs.push_back(Val);
-}
-
-void
-ParamAttrsList::removeAttributes(uint16_t Index, uint16_t Attrs) {
- // Find the index from which to remove the attributes
- for (unsigned i = 0; i < attrs.size(); ++i)
- if (attrs[i].index == Index) {
- attrs[i].attrs &= ~Attrs;
- if (attrs[i].attrs == NoAttributeSet)
- attrs.erase(&attrs[i]);
- return;
- }
-
- // The index wasn't found above
- assert(0 && "Index not found for removeAttributes");
-}
-
//===----------------------------------------------------------------------===//
// Array Type Factory...
//