mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
For PR1146:
Adapt handling of parameter attributes to use the new ParamAttrsList class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35814 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7b5d466c88
commit
5694b6e90e
@ -17,6 +17,7 @@
|
||||
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/ParameterAttributes.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Assembly/Parser.h"
|
||||
@ -231,13 +232,13 @@ struct ValID {
|
||||
|
||||
struct TypeWithAttrs {
|
||||
llvm::PATypeHolder *Ty;
|
||||
FunctionType::ParameterAttributes Attrs;
|
||||
uint16_t Attrs;
|
||||
};
|
||||
|
||||
typedef std::vector<TypeWithAttrs> TypeWithAttrsList;
|
||||
|
||||
struct ArgListEntry {
|
||||
FunctionType::ParameterAttributes Attrs;
|
||||
uint16_t Attrs;
|
||||
llvm::PATypeHolder *Ty;
|
||||
char *Name;
|
||||
};
|
||||
@ -246,7 +247,7 @@ typedef std::vector<struct ArgListEntry> ArgListType;
|
||||
|
||||
struct ValueRefListEntry {
|
||||
Value *Val;
|
||||
FunctionType::ParameterAttributes Attrs;
|
||||
uint16_t Attrs;
|
||||
};
|
||||
|
||||
typedef std::vector<ValueRefListEntry> ValueRefList;
|
||||
|
@ -200,8 +200,6 @@ static struct PerModuleInfo {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} CurModule;
|
||||
|
||||
static struct PerFunctionInfo {
|
||||
@ -962,7 +960,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
|
||||
|
||||
llvm::GlobalValue::LinkageTypes Linkage;
|
||||
llvm::GlobalValue::VisibilityTypes Visibility;
|
||||
llvm::FunctionType::ParameterAttributes ParamAttrs;
|
||||
uint16_t ParamAttrs;
|
||||
llvm::APInt *APIntVal;
|
||||
int64_t SInt64Val;
|
||||
uint64_t UInt64Val;
|
||||
@ -1191,26 +1189,26 @@ OptCallingConv : /*empty*/ { $$ = CallingConv::C; } |
|
||||
CHECK_FOR_ERROR
|
||||
};
|
||||
|
||||
ParamAttr : ZEXT { $$ = FunctionType::ZExtAttribute; }
|
||||
| SEXT { $$ = FunctionType::SExtAttribute; }
|
||||
| INREG { $$ = FunctionType::InRegAttribute; }
|
||||
| SRET { $$ = FunctionType::StructRetAttribute; }
|
||||
ParamAttr : ZEXT { $$ = ZExtAttribute; }
|
||||
| SEXT { $$ = SExtAttribute; }
|
||||
| INREG { $$ = InRegAttribute; }
|
||||
| SRET { $$ = StructRetAttribute; }
|
||||
;
|
||||
|
||||
OptParamAttrs : /* empty */ { $$ = FunctionType::NoAttributeSet; }
|
||||
OptParamAttrs : /* empty */ { $$ = NoAttributeSet; }
|
||||
| OptParamAttrs ParamAttr {
|
||||
$$ = FunctionType::ParameterAttributes($1 | $2);
|
||||
$$ = $1 | $2;
|
||||
}
|
||||
;
|
||||
|
||||
FuncAttr : NORETURN { $$ = FunctionType::NoReturnAttribute; }
|
||||
| NOUNWIND { $$ = FunctionType::NoUnwindAttribute; }
|
||||
FuncAttr : NORETURN { $$ = NoReturnAttribute; }
|
||||
| NOUNWIND { $$ = NoUnwindAttribute; }
|
||||
| ParamAttr
|
||||
;
|
||||
|
||||
OptFuncAttrs : /* empty */ { $$ = FunctionType::NoAttributeSet; }
|
||||
OptFuncAttrs : /* empty */ { $$ = NoAttributeSet; }
|
||||
| OptFuncAttrs FuncAttr {
|
||||
$$ = FunctionType::ParameterAttributes($1 | $2);
|
||||
$$ = $1 | $2;
|
||||
}
|
||||
;
|
||||
|
||||
@ -1299,18 +1297,25 @@ Types
|
||||
}
|
||||
| Types '(' ArgTypeListI ')' OptFuncAttrs {
|
||||
std::vector<const Type*> Params;
|
||||
std::vector<FunctionType::ParameterAttributes> Attrs;
|
||||
Attrs.push_back($5);
|
||||
for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) {
|
||||
ParamAttrsList Attrs;
|
||||
if ($5 != NoAttributeSet)
|
||||
Attrs.addAttributes(0, $5);
|
||||
unsigned index = 1;
|
||||
TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
|
||||
for (; I != E; ++I, ++index) {
|
||||
const Type *Ty = I->Ty->get();
|
||||
Params.push_back(Ty);
|
||||
if (Ty != Type::VoidTy)
|
||||
Attrs.push_back(I->Attrs);
|
||||
if (I->Attrs != NoAttributeSet)
|
||||
Attrs.addAttributes(index, I->Attrs);
|
||||
}
|
||||
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
|
||||
if (isVarArg) Params.pop_back();
|
||||
|
||||
FunctionType *FT = FunctionType::get(*$1, Params, isVarArg, Attrs);
|
||||
ParamAttrsList *ActualAttrs = 0;
|
||||
if (!Attrs.empty())
|
||||
ActualAttrs = new ParamAttrsList(Attrs);
|
||||
FunctionType *FT = FunctionType::get(*$1, Params, isVarArg, ActualAttrs);
|
||||
delete $3; // Delete the argument list
|
||||
delete $1; // Delete the return type handle
|
||||
$$ = new PATypeHolder(HandleUpRefs(FT));
|
||||
@ -1318,18 +1323,26 @@ Types
|
||||
}
|
||||
| VOID '(' ArgTypeListI ')' OptFuncAttrs {
|
||||
std::vector<const Type*> Params;
|
||||
std::vector<FunctionType::ParameterAttributes> Attrs;
|
||||
Attrs.push_back($5);
|
||||
for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) {
|
||||
ParamAttrsList Attrs;
|
||||
if ($5 != NoAttributeSet)
|
||||
Attrs.addAttributes(0, $5);
|
||||
TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
|
||||
unsigned index = 1;
|
||||
for ( ; I != E; ++I, ++index) {
|
||||
const Type* Ty = I->Ty->get();
|
||||
Params.push_back(Ty);
|
||||
if (Ty != Type::VoidTy)
|
||||
Attrs.push_back(I->Attrs);
|
||||
if (I->Attrs != NoAttributeSet)
|
||||
Attrs.addAttributes(index, I->Attrs);
|
||||
}
|
||||
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
|
||||
if (isVarArg) Params.pop_back();
|
||||
|
||||
FunctionType *FT = FunctionType::get($1, Params, isVarArg, Attrs);
|
||||
ParamAttrsList *ActualAttrs = 0;
|
||||
if (!Attrs.empty())
|
||||
ActualAttrs = new ParamAttrsList(Attrs);
|
||||
|
||||
FunctionType *FT = FunctionType::get($1, Params, isVarArg, ActualAttrs);
|
||||
delete $3; // Delete the argument list
|
||||
$$ = new PATypeHolder(HandleUpRefs(FT));
|
||||
CHECK_FOR_ERROR
|
||||
@ -1417,14 +1430,14 @@ ArgTypeListI
|
||||
: ArgTypeList
|
||||
| ArgTypeList ',' DOTDOTDOT {
|
||||
$$=$1;
|
||||
TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
|
||||
TypeWithAttrs TWA; TWA.Attrs = NoAttributeSet;
|
||||
TWA.Ty = new PATypeHolder(Type::VoidTy);
|
||||
$$->push_back(TWA);
|
||||
CHECK_FOR_ERROR
|
||||
}
|
||||
| DOTDOTDOT {
|
||||
$$ = new TypeWithAttrsList;
|
||||
TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
|
||||
TypeWithAttrs TWA; TWA.Attrs = NoAttributeSet;
|
||||
TWA.Ty = new PATypeHolder(Type::VoidTy);
|
||||
$$->push_back(TWA);
|
||||
CHECK_FOR_ERROR
|
||||
@ -2087,7 +2100,7 @@ ArgList : ArgListH {
|
||||
struct ArgListEntry E;
|
||||
E.Ty = new PATypeHolder(Type::VoidTy);
|
||||
E.Name = 0;
|
||||
E.Attrs = FunctionType::NoAttributeSet;
|
||||
E.Attrs = NoAttributeSet;
|
||||
$$->push_back(E);
|
||||
CHECK_FOR_ERROR
|
||||
}
|
||||
@ -2096,7 +2109,7 @@ ArgList : ArgListH {
|
||||
struct ArgListEntry E;
|
||||
E.Ty = new PATypeHolder(Type::VoidTy);
|
||||
E.Name = 0;
|
||||
E.Attrs = FunctionType::NoAttributeSet;
|
||||
E.Attrs = NoAttributeSet;
|
||||
$$->push_back(E);
|
||||
CHECK_FOR_ERROR
|
||||
}
|
||||
@ -2117,24 +2130,31 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
|
||||
GEN_ERROR("Reference to abstract result: "+ $2->get()->getDescription());
|
||||
|
||||
std::vector<const Type*> ParamTypeList;
|
||||
std::vector<FunctionType::ParameterAttributes> ParamAttrs;
|
||||
ParamAttrs.push_back($7);
|
||||
ParamAttrsList ParamAttrs;
|
||||
if ($7 != NoAttributeSet)
|
||||
ParamAttrs.addAttributes(0, $7);
|
||||
if ($5) { // If there are arguments...
|
||||
for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I) {
|
||||
unsigned index = 1;
|
||||
for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I, ++index) {
|
||||
const Type* Ty = I->Ty->get();
|
||||
if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
|
||||
GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
|
||||
ParamTypeList.push_back(Ty);
|
||||
if (Ty != Type::VoidTy)
|
||||
ParamAttrs.push_back(I->Attrs);
|
||||
if (I->Attrs != NoAttributeSet)
|
||||
ParamAttrs.addAttributes(index, I->Attrs);
|
||||
}
|
||||
}
|
||||
|
||||
bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
|
||||
if (isVarArg) ParamTypeList.pop_back();
|
||||
|
||||
FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg,
|
||||
ParamAttrs);
|
||||
ParamAttrsList *ActualAttrs = 0;
|
||||
if (!ParamAttrs.empty())
|
||||
ActualAttrs = new ParamAttrsList(ParamAttrs);
|
||||
|
||||
FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg,
|
||||
ActualAttrs);
|
||||
const PointerType *PFT = PointerType::get(FT);
|
||||
delete $2;
|
||||
|
||||
@ -2465,17 +2485,24 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
||||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
|
||||
// Pull out the types of all of the arguments...
|
||||
std::vector<const Type*> ParamTypes;
|
||||
FunctionType::ParamAttrsList ParamAttrs;
|
||||
ParamAttrs.push_back($8);
|
||||
for (ValueRefList::iterator I = $6->begin(), E = $6->end(); I != E; ++I) {
|
||||
ParamAttrsList ParamAttrs;
|
||||
if ($8 != NoAttributeSet)
|
||||
ParamAttrs.addAttributes(0, $8);
|
||||
ValueRefList::iterator I = $6->begin(), E = $6->end();
|
||||
unsigned index = 1;
|
||||
for (; I != E; ++I, ++index) {
|
||||
const Type *Ty = I->Val->getType();
|
||||
if (Ty == Type::VoidTy)
|
||||
GEN_ERROR("Short call syntax cannot be used with varargs");
|
||||
ParamTypes.push_back(Ty);
|
||||
ParamAttrs.push_back(I->Attrs);
|
||||
if (I->Attrs != NoAttributeSet)
|
||||
ParamAttrs.addAttributes(index, I->Attrs);
|
||||
}
|
||||
|
||||
Ty = FunctionType::get($3->get(), ParamTypes, false, ParamAttrs);
|
||||
ParamAttrsList *Attrs = 0;
|
||||
if (!ParamAttrs.empty())
|
||||
Attrs = new ParamAttrsList(ParamAttrs);
|
||||
Ty = FunctionType::get($3->get(), ParamTypes, false, Attrs);
|
||||
PFTy = PointerType::get(Ty);
|
||||
}
|
||||
|
||||
@ -2764,17 +2791,25 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
||||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
|
||||
// Pull out the types of all of the arguments...
|
||||
std::vector<const Type*> ParamTypes;
|
||||
FunctionType::ParamAttrsList ParamAttrs;
|
||||
ParamAttrs.push_back($8);
|
||||
for (ValueRefList::iterator I = $6->begin(), E = $6->end(); I != E; ++I) {
|
||||
ParamAttrsList ParamAttrs;
|
||||
if ($8 != NoAttributeSet)
|
||||
ParamAttrs.addAttributes(0, $8);
|
||||
unsigned index = 1;
|
||||
ValueRefList::iterator I = $6->begin(), E = $6->end();
|
||||
for (; I != E; ++I, ++index) {
|
||||
const Type *Ty = I->Val->getType();
|
||||
if (Ty == Type::VoidTy)
|
||||
GEN_ERROR("Short call syntax cannot be used with varargs");
|
||||
ParamTypes.push_back(Ty);
|
||||
ParamAttrs.push_back(I->Attrs);
|
||||
if (I->Attrs != NoAttributeSet)
|
||||
ParamAttrs.addAttributes(index, I->Attrs);
|
||||
}
|
||||
|
||||
Ty = FunctionType::get($3->get(), ParamTypes, false, ParamAttrs);
|
||||
ParamAttrsList *Attrs = 0;
|
||||
if (!ParamAttrs.empty())
|
||||
Attrs = new ParamAttrsList(ParamAttrs);
|
||||
|
||||
Ty = FunctionType::get($3->get(), ParamTypes, false, Attrs);
|
||||
PFTy = PointerType::get(Ty);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
#include "llvm/ParameterAttributes.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||
@ -802,10 +803,11 @@ void SelectionDAGLowering::visitRet(ReturnInst &I) {
|
||||
else
|
||||
TmpVT = MVT::i32;
|
||||
const FunctionType *FTy = I.getParent()->getParent()->getFunctionType();
|
||||
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
||||
ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
|
||||
if (FTy->paramHasAttr(0, FunctionType::SExtAttribute))
|
||||
if (Attrs && Attrs->paramHasAttr(0, SExtAttribute))
|
||||
ExtendKind = ISD::SIGN_EXTEND;
|
||||
if (FTy->paramHasAttr(0, FunctionType::ZExtAttribute))
|
||||
if (Attrs && Attrs->paramHasAttr(0, ZExtAttribute))
|
||||
ExtendKind = ISD::ZERO_EXTEND;
|
||||
RetOp = DAG.getNode(ExtendKind, TmpVT, RetOp);
|
||||
}
|
||||
@ -2508,6 +2510,7 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
||||
SDOperand Callee, unsigned OpIdx) {
|
||||
const PointerType *PT = cast<PointerType>(CalledValueTy);
|
||||
const FunctionType *FTy = cast<FunctionType>(PT->getElementType());
|
||||
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
||||
|
||||
TargetLowering::ArgListTy Args;
|
||||
TargetLowering::ArgListEntry Entry;
|
||||
@ -2516,16 +2519,16 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
||||
Value *Arg = I.getOperand(i);
|
||||
SDOperand ArgNode = getValue(Arg);
|
||||
Entry.Node = ArgNode; Entry.Ty = Arg->getType();
|
||||
Entry.isSExt = FTy->paramHasAttr(i, FunctionType::SExtAttribute);
|
||||
Entry.isZExt = FTy->paramHasAttr(i, FunctionType::ZExtAttribute);
|
||||
Entry.isInReg = FTy->paramHasAttr(i, FunctionType::InRegAttribute);
|
||||
Entry.isSRet = FTy->paramHasAttr(i, FunctionType::StructRetAttribute);
|
||||
Entry.isSExt = Attrs && Attrs->paramHasAttr(i, SExtAttribute);
|
||||
Entry.isZExt = Attrs && Attrs->paramHasAttr(i, ZExtAttribute);
|
||||
Entry.isInReg = Attrs && Attrs->paramHasAttr(i, InRegAttribute);
|
||||
Entry.isSRet = Attrs && Attrs->paramHasAttr(i, StructRetAttribute);
|
||||
Args.push_back(Entry);
|
||||
}
|
||||
|
||||
std::pair<SDOperand,SDOperand> Result =
|
||||
TLI.LowerCallTo(getRoot(), I.getType(),
|
||||
FTy->paramHasAttr(0,FunctionType::SExtAttribute),
|
||||
Attrs && Attrs->paramHasAttr(0, SExtAttribute),
|
||||
FTy->isVarArg(), CallingConv, IsTailCall,
|
||||
Callee, Args, DAG);
|
||||
if (I.getType() != Type::VoidTy)
|
||||
@ -3346,6 +3349,7 @@ static SDOperand ExpandScalarFormalArgs(MVT::ValueType VT, SDNode *Arg,
|
||||
std::vector<SDOperand>
|
||||
TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) {
|
||||
const FunctionType *FTy = F.getFunctionType();
|
||||
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
||||
// Add CC# and isVararg as operands to the FORMAL_ARGUMENTS node.
|
||||
std::vector<SDOperand> Ops;
|
||||
Ops.push_back(DAG.getRoot());
|
||||
@ -3364,13 +3368,13 @@ TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) {
|
||||
|
||||
// FIXME: Distinguish between a formal with no [sz]ext attribute from one
|
||||
// that is zero extended!
|
||||
if (FTy->paramHasAttr(j, FunctionType::ZExtAttribute))
|
||||
if (Attrs && Attrs->paramHasAttr(j, ZExtAttribute))
|
||||
Flags &= ~(ISD::ParamFlags::SExt);
|
||||
if (FTy->paramHasAttr(j, FunctionType::SExtAttribute))
|
||||
if (Attrs && Attrs->paramHasAttr(j, SExtAttribute))
|
||||
Flags |= ISD::ParamFlags::SExt;
|
||||
if (FTy->paramHasAttr(j, FunctionType::InRegAttribute))
|
||||
if (Attrs && Attrs->paramHasAttr(j, InRegAttribute))
|
||||
Flags |= ISD::ParamFlags::InReg;
|
||||
if (FTy->paramHasAttr(j, FunctionType::StructRetAttribute))
|
||||
if (Attrs && Attrs->paramHasAttr(j, StructRetAttribute))
|
||||
Flags |= ISD::ParamFlags::StructReturn;
|
||||
Flags |= (OriginalAlignment << ISD::ParamFlags::OrigAlignmentOffs);
|
||||
|
||||
@ -3444,10 +3448,10 @@ TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) {
|
||||
case Promote: {
|
||||
SDOperand Op(Result, i++);
|
||||
if (MVT::isInteger(VT)) {
|
||||
if (FTy->paramHasAttr(Idx, FunctionType::SExtAttribute))
|
||||
if (Attrs && Attrs->paramHasAttr(Idx, SExtAttribute))
|
||||
Op = DAG.getNode(ISD::AssertSext, Op.getValueType(), Op,
|
||||
DAG.getValueType(VT));
|
||||
else if (FTy->paramHasAttr(Idx, FunctionType::ZExtAttribute))
|
||||
else if (Attrs && Attrs->paramHasAttr(Idx, ZExtAttribute))
|
||||
Op = DAG.getNode(ISD::AssertZext, Op.getValueType(), Op,
|
||||
DAG.getValueType(VT));
|
||||
Op = DAG.getNode(ISD::TRUNCATE, VT, Op);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/ParameterAttributes.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
@ -350,11 +351,12 @@ void CWriter::printStructReturnPointerFunctionType(std::ostream &Out,
|
||||
FunctionType::param_iterator I = FTy->param_begin(), E = FTy->param_end();
|
||||
const Type *RetTy = cast<PointerType>(I->get())->getElementType();
|
||||
unsigned Idx = 1;
|
||||
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
||||
for (++I; I != E; ++I) {
|
||||
if (PrintedType)
|
||||
FunctionInnards << ", ";
|
||||
printType(FunctionInnards, *I,
|
||||
/*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute), "");
|
||||
/*isSigned=*/Attrs && Attrs->paramHasAttr(Idx, SExtAttribute), "");
|
||||
PrintedType = true;
|
||||
}
|
||||
if (FTy->isVarArg()) {
|
||||
@ -366,7 +368,7 @@ void CWriter::printStructReturnPointerFunctionType(std::ostream &Out,
|
||||
FunctionInnards << ')';
|
||||
std::string tstr = FunctionInnards.str();
|
||||
printType(Out, RetTy,
|
||||
/*isSigned=*/FTy->paramHasAttr(0, FunctionType::SExtAttribute), tstr);
|
||||
/*isSigned=*/Attrs && Attrs->paramHasAttr(0, SExtAttribute), tstr);
|
||||
}
|
||||
|
||||
std::ostream &
|
||||
@ -421,13 +423,14 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
|
||||
const FunctionType *FTy = cast<FunctionType>(Ty);
|
||||
std::stringstream FunctionInnards;
|
||||
FunctionInnards << " (" << NameSoFar << ") (";
|
||||
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
||||
unsigned Idx = 1;
|
||||
for (FunctionType::param_iterator I = FTy->param_begin(),
|
||||
E = FTy->param_end(); I != E; ++I) {
|
||||
if (I != FTy->param_begin())
|
||||
FunctionInnards << ", ";
|
||||
printType(FunctionInnards, *I,
|
||||
/*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute), "");
|
||||
/*isSigned=*/Attrs && Attrs->paramHasAttr(Idx, SExtAttribute), "");
|
||||
++Idx;
|
||||
}
|
||||
if (FTy->isVarArg()) {
|
||||
@ -439,7 +442,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
|
||||
FunctionInnards << ')';
|
||||
std::string tstr = FunctionInnards.str();
|
||||
printType(Out, FTy->getReturnType(),
|
||||
/*isSigned=*/FTy->paramHasAttr(0, FunctionType::SExtAttribute), tstr);
|
||||
/*isSigned=*/Attrs && Attrs->paramHasAttr(0, SExtAttribute), tstr);
|
||||
return Out;
|
||||
}
|
||||
case Type::StructTyID: {
|
||||
@ -1801,6 +1804,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
|
||||
|
||||
// Loop over the arguments, printing them...
|
||||
const FunctionType *FT = cast<FunctionType>(F->getFunctionType());
|
||||
const ParamAttrsList *Attrs = FT->getParamAttrs();
|
||||
|
||||
std::stringstream FunctionInnards;
|
||||
|
||||
@ -1828,7 +1832,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
|
||||
else
|
||||
ArgName = "";
|
||||
printType(FunctionInnards, I->getType(),
|
||||
/*isSigned=*/FT->paramHasAttr(Idx, FunctionType::SExtAttribute),
|
||||
/*isSigned=*/Attrs && Attrs->paramHasAttr(Idx, SExtAttribute),
|
||||
ArgName);
|
||||
PrintedArg = true;
|
||||
++Idx;
|
||||
@ -1849,7 +1853,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
|
||||
for (; I != E; ++I) {
|
||||
if (PrintedArg) FunctionInnards << ", ";
|
||||
printType(FunctionInnards, *I,
|
||||
/*isSigned=*/FT->paramHasAttr(Idx, FunctionType::SExtAttribute));
|
||||
/*isSigned=*/Attrs && Attrs->paramHasAttr(Idx, SExtAttribute));
|
||||
PrintedArg = true;
|
||||
++Idx;
|
||||
}
|
||||
@ -1877,7 +1881,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
|
||||
|
||||
// Print out the return type and the signature built above.
|
||||
printType(Out, RetTy,
|
||||
/*isSigned=*/FT->paramHasAttr(0, FunctionType::SExtAttribute),
|
||||
/*isSigned=*/ Attrs && Attrs->paramHasAttr(0, SExtAttribute),
|
||||
FunctionInnards.str());
|
||||
}
|
||||
|
||||
@ -2573,6 +2577,7 @@ void CWriter::visitCallInst(CallInst &I) {
|
||||
++ArgNo;
|
||||
}
|
||||
|
||||
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
||||
bool PrintedArg = false;
|
||||
unsigned Idx = 1;
|
||||
for (; AI != AE; ++AI, ++ArgNo, ++Idx) {
|
||||
@ -2581,7 +2586,7 @@ void CWriter::visitCallInst(CallInst &I) {
|
||||
(*AI)->getType() != FTy->getParamType(ArgNo)) {
|
||||
Out << '(';
|
||||
printType(Out, FTy->getParamType(ArgNo),
|
||||
/*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute));
|
||||
/*isSigned=*/Attrs && Attrs->paramHasAttr(Idx, SExtAttribute));
|
||||
Out << ')';
|
||||
}
|
||||
writeOperand(*AI);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
#include "llvm/ParameterAttributes.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/Analysis/ConstantsScanner.h"
|
||||
#include "llvm/Support/CallSite.h"
|
||||
@ -1131,7 +1132,8 @@ void MSILWriter::printStaticInitializerList() {
|
||||
|
||||
void MSILWriter::printFunction(const Function& F) {
|
||||
const FunctionType* FTy = F.getFunctionType();
|
||||
bool isSigned = FTy->paramHasAttr(0,FunctionType::SExtAttribute);
|
||||
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
||||
bool isSigned = Attrs && Attrs->paramHasAttr(0, SExtAttribute);
|
||||
Out << "\n.method static ";
|
||||
Out << (F.hasInternalLinkage() ? "private " : "public ");
|
||||
if (F.isVarArg()) Out << "vararg ";
|
||||
@ -1142,7 +1144,7 @@ void MSILWriter::printFunction(const Function& F) {
|
||||
unsigned ArgIdx = 1;
|
||||
for (Function::const_arg_iterator I = F.arg_begin(), E = F.arg_end(); I!=E;
|
||||
++I, ++ArgIdx) {
|
||||
isSigned = FTy->paramHasAttr(ArgIdx,FunctionType::SExtAttribute);
|
||||
isSigned = Attrs && Attrs->paramHasAttr(ArgIdx, SExtAttribute);
|
||||
if (I!=F.arg_begin()) Out << ", ";
|
||||
Out << getTypeName(I->getType(),isSigned) << getValueName(I);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user