diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-06-06 09:36:29 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-06-06 09:36:29 +0000 |
commit | 18adbf5f07af12bb6fbc87b25740a0d5ce46eefc (patch) | |
tree | 97b1935740bdfd489409e59e5333545ed0d8d6ed /clang/lib/CodeGen/CGCall.cpp | |
parent | 6813eb125f2d819548e85685059bdda2ee86b04f (diff) | |
download | bcm5719-llvm-18adbf5f07af12bb6fbc87b25740a0d5ce46eefc.tar.gz bcm5719-llvm-18adbf5f07af12bb6fbc87b25740a0d5ce46eefc.zip |
Add new ABIArgInfo kind: Extend. This allows target to implement its own argument
zero/sign extension logic (consider, e.g. target has only 64 bit registers and thus
i32's should be extended as well).
llvm-svn: 72998
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index b46e860b2ef..b10b9c2d9de 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -314,6 +314,7 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) { case ABIArgInfo::Expand: assert(0 && "Invalid ABI kind for return argument"); + case ABIArgInfo::Extend: case ABIArgInfo::Direct: ResultType = ConvertType(RetTy); break; @@ -353,7 +354,8 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) { ArgTys.push_back(llvm::PointerType::getUnqual(LTy)); break; } - + + case ABIArgInfo::Extend: case ABIArgInfo::Direct: ArgTys.push_back(ConvertType(it->type)); break; @@ -394,14 +396,14 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, unsigned Index = 1; const ABIArgInfo &RetAI = FI.getReturnInfo(); switch (RetAI.getKind()) { + case ABIArgInfo::Extend: + if (RetTy->isSignedIntegerType()) { + RetAttrs |= llvm::Attribute::SExt; + } else if (RetTy->isUnsignedIntegerType()) { + RetAttrs |= llvm::Attribute::ZExt; + } + // FALLTHROUGH case ABIArgInfo::Direct: - if (RetTy->isPromotableIntegerType()) { - if (RetTy->isSignedIntegerType()) { - RetAttrs |= llvm::Attribute::SExt; - } else if (RetTy->isUnsignedIntegerType()) { - RetAttrs |= llvm::Attribute::ZExt; - } - } break; case ABIArgInfo::Indirect: @@ -452,15 +454,15 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, FuncAttrs &= ~(llvm::Attribute::ReadOnly | llvm::Attribute::ReadNone); break; - + + case ABIArgInfo::Extend: + if (ParamType->isSignedIntegerType()) { + Attributes |= llvm::Attribute::SExt; + } else if (ParamType->isUnsignedIntegerType()) { + Attributes |= llvm::Attribute::ZExt; + } + // FALLS THROUGH case ABIArgInfo::Direct: - if (ParamType->isPromotableIntegerType()) { - if (ParamType->isSignedIntegerType()) { - Attributes |= llvm::Attribute::SExt; - } else if (ParamType->isUnsignedIntegerType()) { - Attributes |= llvm::Attribute::ZExt; - } - } if (RegParm > 0 && (ParamType->isIntegerType() || ParamType->isPointerType())) { RegParm -= @@ -536,7 +538,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, EmitParmDecl(*Arg, V); break; } - + + case ABIArgInfo::Extend: case ABIArgInfo::Direct: { assert(AI != Fn->arg_end() && "Argument mismatch!"); llvm::Value* V = AI; @@ -618,10 +621,10 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, llvm::Value *RV = 0; // Functions with no result always return void. - if (ReturnValue) { + if (ReturnValue) { QualType RetTy = FI.getReturnType(); const ABIArgInfo &RetAI = FI.getReturnInfo(); - + switch (RetAI.getKind()) { case ABIArgInfo::Indirect: if (RetTy->isAnyComplexType()) { @@ -630,11 +633,12 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, } else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) { EmitAggregateCopy(CurFn->arg_begin(), ReturnValue, RetTy); } else { - EmitStoreOfScalar(Builder.CreateLoad(ReturnValue), CurFn->arg_begin(), + EmitStoreOfScalar(Builder.CreateLoad(ReturnValue), CurFn->arg_begin(), false, RetTy); } break; + case ABIArgInfo::Extend: case ABIArgInfo::Direct: // The internal return value temp always will have // pointer-to-return-type type. @@ -705,6 +709,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, } break; + case ABIArgInfo::Extend: case ABIArgInfo::Direct: if (RV.isScalar()) { Args.push_back(RV.getScalarVal()); @@ -791,6 +796,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, return RValue::getAggregate(Args[0]); return RValue::get(EmitLoadOfScalar(Args[0], false, RetTy)); + case ABIArgInfo::Extend: case ABIArgInfo::Direct: if (RetTy->isAnyComplexType()) { llvm::Value *Real = Builder.CreateExtractValue(CI, 0); |