mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-16 00:33:10 +00:00
Add methods which query for the specific attribute instead of using the
enums. This allows for better encapsulation of the Attributes class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165132 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
565ebde5fe
commit
847d165459
@ -1272,6 +1272,14 @@ public:
|
||||
return paramHasAttr(~0, N);
|
||||
}
|
||||
|
||||
/// @brief Determine whether the call or the callee has the given attributes.
|
||||
bool paramHasSExtAttr(unsigned i) const;
|
||||
bool paramHasZExtAttr(unsigned i) const;
|
||||
bool paramHasInRegAttr(unsigned i) const;
|
||||
bool paramHasStructRetAttr(unsigned i) const;
|
||||
bool paramHasNestAttr(unsigned i) const;
|
||||
bool paramHasByValAttr(unsigned i) const;
|
||||
|
||||
/// @brief Determine whether the call or the callee has the given attribute.
|
||||
bool paramHasAttr(unsigned i, Attributes attr) const;
|
||||
|
||||
@ -3034,6 +3042,14 @@ public:
|
||||
return paramHasAttr(~0, N);
|
||||
}
|
||||
|
||||
/// @brief Determine whether the call or the callee has the given attributes.
|
||||
bool paramHasSExtAttr(unsigned i) const;
|
||||
bool paramHasZExtAttr(unsigned i) const;
|
||||
bool paramHasInRegAttr(unsigned i) const;
|
||||
bool paramHasStructRetAttr(unsigned i) const;
|
||||
bool paramHasNestAttr(unsigned i) const;
|
||||
bool paramHasByValAttr(unsigned i) const;
|
||||
|
||||
/// @brief Determine whether the call or the callee has the given attribute.
|
||||
bool paramHasAttr(unsigned i, Attributes attr) const;
|
||||
|
||||
|
@ -189,6 +189,26 @@ public:
|
||||
CALLSITE_DELEGATE_GETTER(hasFnAttr(N));
|
||||
}
|
||||
|
||||
/// paramHas*Attr - whether the call or the callee has the given attribute.
|
||||
bool paramHasSExtAttr(unsigned i) const {
|
||||
CALLSITE_DELEGATE_GETTER(paramHasSExtAttr(i));
|
||||
}
|
||||
bool paramHasZExtAttr(unsigned i) const {
|
||||
CALLSITE_DELEGATE_GETTER(paramHasZExtAttr(i));
|
||||
}
|
||||
bool paramHasInRegAttr(unsigned i) const {
|
||||
CALLSITE_DELEGATE_GETTER(paramHasInRegAttr(i));
|
||||
}
|
||||
bool paramHasStructRetAttr(unsigned i) const {
|
||||
CALLSITE_DELEGATE_GETTER(paramHasStructRetAttr(i));
|
||||
}
|
||||
bool paramHasNestAttr(unsigned i) const {
|
||||
CALLSITE_DELEGATE_GETTER(paramHasNestAttr(i));
|
||||
}
|
||||
bool paramHasByValAttr(unsigned i) const {
|
||||
CALLSITE_DELEGATE_GETTER(paramHasByValAttr(i));
|
||||
}
|
||||
|
||||
/// paramHasAttr - whether the call or the callee has the given attribute.
|
||||
bool paramHasAttr(uint16_t i, Attributes attr) const {
|
||||
CALLSITE_DELEGATE_GETTER(paramHasAttr(i, attr));
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user