summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-10-03 17:54:26 +0000
committerBill Wendling <isanbard@gmail.com>2012-10-03 17:54:26 +0000
commit8baa61d85d3faa05882e5a6b45bcc11c78f60d40 (patch)
treea5db4351f1c5ed8d142a0f6774055847e10f7f09 /llvm/lib
parent53fefd1f6a19971509ae9440f6a66e56d08e736b (diff)
downloadbcm5719-llvm-8baa61d85d3faa05882e5a6b45bcc11c78f60d40.tar.gz
bcm5719-llvm-8baa61d85d3faa05882e5a6b45bcc11c78f60d40.zip
Add methods which query for the specific attribute instead of using the
enums. This allows for better encapsulation of the Attributes class. llvm-svn: 165132
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/ARM/ARMFastISel.cpp12
-rw-r--r--llvm/lib/Target/X86/X86FastISel.cpp20
-rw-r--r--llvm/lib/VMCore/Instructions.cpp96
3 files changed, 112 insertions, 16 deletions
diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp
index 8933a02701c..ecd48452e36 100644
--- a/llvm/lib/Target/ARM/ARMFastISel.cpp
+++ b/llvm/lib/Target/ARM/ARMFastISel.cpp
@@ -2320,16 +2320,16 @@ bool ARMFastISel::SelectCall(const Instruction *I,
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
- if (CS.paramHasAttr(AttrInd, Attribute::SExt))
+ if (CS.paramHasSExtAttr(AttrInd))
Flags.setSExt();
- if (CS.paramHasAttr(AttrInd, Attribute::ZExt))
+ if (CS.paramHasZExtAttr(AttrInd))
Flags.setZExt();
// FIXME: Only handle *easy* calls for now.
- if (CS.paramHasAttr(AttrInd, Attribute::InReg) ||
- CS.paramHasAttr(AttrInd, Attribute::StructRet) ||
- CS.paramHasAttr(AttrInd, Attribute::Nest) ||
- CS.paramHasAttr(AttrInd, Attribute::ByVal))
+ if (CS.paramHasInRegAttr(AttrInd) ||
+ CS.paramHasStructRetAttr(AttrInd) ||
+ CS.paramHasNestAttr(AttrInd) ||
+ CS.paramHasByValAttr(AttrInd))
return false;
Type *ArgTy = (*i)->getType();
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index fd279a169cf..cf14fe05212 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -1541,9 +1541,9 @@ static unsigned computeBytesPoppedByCallee(const X86Subtarget &Subtarget,
CallingConv::ID CC = CS.getCallingConv();
if (CC == CallingConv::Fast || CC == CallingConv::GHC)
return 0;
- if (!CS.paramHasAttr(1, Attribute::StructRet))
+ if (!CS.paramHasStructRetAttr(1))
return 0;
- if (CS.paramHasAttr(1, Attribute::InReg))
+ if (CS.paramHasInRegAttr(1))
return 0;
return 4;
}
@@ -1622,12 +1622,12 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
Value *ArgVal = *i;
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
- if (CS.paramHasAttr(AttrInd, Attribute::SExt))
+ if (CS.paramHasSExtAttr(AttrInd))
Flags.setSExt();
- if (CS.paramHasAttr(AttrInd, Attribute::ZExt))
+ if (CS.paramHasZExtAttr(AttrInd))
Flags.setZExt();
- if (CS.paramHasAttr(AttrInd, Attribute::ByVal)) {
+ if (CS.paramHasByValAttr(AttrInd)) {
PointerType *Ty = cast<PointerType>(ArgVal->getType());
Type *ElementTy = Ty->getElementType();
unsigned FrameSize = TD.getTypeAllocSize(ElementTy);
@@ -1641,9 +1641,9 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
return false;
}
- if (CS.paramHasAttr(AttrInd, Attribute::InReg))
+ if (CS.paramHasInRegAttr(AttrInd))
Flags.setInReg();
- if (CS.paramHasAttr(AttrInd, Attribute::Nest))
+ if (CS.paramHasNestAttr(AttrInd))
Flags.setNest();
// If this is an i1/i8/i16 argument, promote to i32 to avoid an extra
@@ -1911,11 +1911,11 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
ISD::InputArg MyFlags;
MyFlags.VT = RegisterVT.getSimpleVT();
MyFlags.Used = !CS.getInstruction()->use_empty();
- if (CS.paramHasAttr(0, Attribute::SExt))
+ if (CS.paramHasSExtAttr(0))
MyFlags.Flags.setSExt();
- if (CS.paramHasAttr(0, Attribute::ZExt))
+ if (CS.paramHasZExtAttr(0))
MyFlags.Flags.setZExt();
- if (CS.paramHasAttr(0, Attribute::InReg))
+ if (CS.paramHasInRegAttr(0))
MyFlags.Flags.setInReg();
Ins.push_back(MyFlags);
}
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index d5b756dac09..b3acbc42410 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -342,6 +342,54 @@ void CallInst::removeAttribute(unsigned i, Attributes attr) {
setAttributes(PAL);
}
+bool CallInst::paramHasSExtAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasSExtAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasSExtAttr();
+ return false;
+}
+
+bool CallInst::paramHasZExtAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasZExtAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasZExtAttr();
+ return false;
+}
+
+bool CallInst::paramHasInRegAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasInRegAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasInRegAttr();
+ return false;
+}
+
+bool CallInst::paramHasStructRetAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasStructRetAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasStructRetAttr();
+ return false;
+}
+
+bool CallInst::paramHasNestAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasNestAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasNestAttr();
+ return false;
+}
+
+bool CallInst::paramHasByValAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasByValAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasByValAttr();
+ return false;
+}
+
bool CallInst::paramHasAttr(unsigned i, Attributes attr) const {
if (AttributeList.paramHasAttr(i, attr))
return true;
@@ -562,6 +610,54 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
return setSuccessor(idx, B);
}
+bool InvokeInst::paramHasSExtAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasSExtAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasSExtAttr();
+ return false;
+}
+
+bool InvokeInst::paramHasZExtAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasZExtAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasZExtAttr();
+ return false;
+}
+
+bool InvokeInst::paramHasInRegAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasInRegAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasInRegAttr();
+ return false;
+}
+
+bool InvokeInst::paramHasStructRetAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasStructRetAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasStructRetAttr();
+ return false;
+}
+
+bool InvokeInst::paramHasNestAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasNestAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasNestAttr();
+ return false;
+}
+
+bool InvokeInst::paramHasByValAttr(unsigned i) const {
+ if (AttributeList.getParamAttributes(i).hasByValAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(i).hasByValAttr();
+ return false;
+}
+
bool InvokeInst::paramHasAttr(unsigned i, Attributes attr) const {
if (AttributeList.paramHasAttr(i, attr))
return true;
OpenPOWER on IntegriCloud