@@ -2982,21 +2982,108 @@ void MSP430TargetCodeGenInfo::SetTargetAttributes(const Decl *D,
2982
2982
2983
2983
namespace {
2984
2984
2985
+ class Mico32ABIInfo : public ABIInfo {
2986
+ public:
2987
+ Mico32ABIInfo (CodeGenTypes &CGT) : ABIInfo(CGT) {}
2988
+
2989
+ bool isPromotableIntegerType (QualType Ty) const ;
2990
+
2991
+ ABIArgInfo classifyReturnType (QualType RetTy) const ;
2992
+ ABIArgInfo classifyArgumentType (QualType RetTy) const ;
2993
+ virtual void computeInfo (CGFunctionInfo &FI) const ;
2994
+ virtual llvm::Value *EmitVAArg (llvm::Value *VAListAddr, QualType Ty,
2995
+ CodeGenFunction &CGF) const ;
2996
+ };
2997
+
2985
2998
class Mico32TargetCodeGenInfo : public TargetCodeGenInfo {
2986
2999
public:
2987
3000
Mico32TargetCodeGenInfo (CodeGenTypes &CGT)
2988
- : TargetCodeGenInfo(new DefaultABIInfo (CGT)) {}
3001
+ : TargetCodeGenInfo(new Mico32ABIInfo (CGT)) {}
2989
3002
void SetTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
2990
3003
CodeGen::CodeGenModule &M) const ;
2991
3004
};
2992
3005
2993
3006
}
2994
3007
3008
+ // Copied from MBlaze
3009
+ bool Mico32ABIInfo::isPromotableIntegerType (QualType Ty) const {
3010
+ // Extend all 8 and 16 bit quantities.
3011
+ if (const BuiltinType *BT = Ty->getAs <BuiltinType>())
3012
+ switch (BT->getKind ()) {
3013
+ case BuiltinType::Bool:
3014
+ case BuiltinType::Char_S:
3015
+ case BuiltinType::Char_U:
3016
+ case BuiltinType::SChar:
3017
+ case BuiltinType::UChar:
3018
+ case BuiltinType::Short:
3019
+ case BuiltinType::UShort:
3020
+ return true ;
3021
+ default :
3022
+ return false ;
3023
+ }
3024
+ return false ;
3025
+ }
3026
+
3027
+ void Mico32ABIInfo::computeInfo (CGFunctionInfo &FI) const {
3028
+ FI.getReturnInfo () = classifyReturnType (FI.getReturnType ());
3029
+ for (CGFunctionInfo::arg_iterator it = FI.arg_begin (), ie = FI.arg_end ();
3030
+ it != ie; ++it)
3031
+ it->info = classifyArgumentType (it->type );
3032
+ }
3033
+
3034
+ // Copied from MIPS
3035
+ ABIArgInfo Mico32ABIInfo::classifyArgumentType (QualType Ty) const {
3036
+ if (isAggregateTypeForABI (Ty)) {
3037
+ // Ignore empty aggregates.
3038
+ if (getContext ().getTypeSize (Ty) == 0 )
3039
+ return ABIArgInfo::getIgnore ();
3040
+
3041
+ // Records with non trivial destructors/constructors should not be passed
3042
+ // by value.
3043
+ if (isRecordWithNonTrivialDestructorOrCopyConstructor (Ty))
3044
+ return ABIArgInfo::getIndirect (0 , /* ByVal=*/ false );
3045
+
3046
+ return ABIArgInfo::getIndirect (0 );
3047
+ }
3048
+
3049
+ // Treat an enum type as its underlying type.
3050
+ if (const EnumType *EnumTy = Ty->getAs <EnumType>())
3051
+ Ty = EnumTy->getDecl ()->getIntegerType ();
3052
+
3053
+ return (isPromotableIntegerType (Ty) ?
3054
+ ABIArgInfo::getExtend () : ABIArgInfo::getDirect ());
3055
+ }
3056
+
3057
+ // Copied from MIPS
3058
+ ABIArgInfo Mico32ABIInfo::classifyReturnType (QualType RetTy) const {
3059
+ if (RetTy->isVoidType ())
3060
+ return ABIArgInfo::getIgnore ();
3061
+
3062
+ if (isAggregateTypeForABI (RetTy)) {
3063
+ // FIXME: Do we want to do a direct return of aggregates of < 8 bytes.
3064
+ return ABIArgInfo::getIndirect (0 );
3065
+ }
3066
+
3067
+ // Treat an enum type as its underlying type.
3068
+ if (const EnumType *EnumTy = RetTy->getAs <EnumType>())
3069
+ RetTy = EnumTy->getDecl ()->getIntegerType ();
3070
+
3071
+ return (RetTy->isPromotableIntegerType () ?
3072
+ ABIArgInfo::getExtend () : ABIArgInfo::getDirect ());
3073
+ }
3074
+
3075
+
2995
3076
void Mico32TargetCodeGenInfo::SetTargetAttributes (const Decl *D,
2996
3077
llvm::GlobalValue *GV,
2997
3078
CodeGen::CodeGenModule &M) const {
2998
3079
}
2999
3080
3081
+ llvm::Value *Mico32ABIInfo::EmitVAArg (llvm::Value *VAListAddr, QualType Ty,
3082
+ CodeGenFunction &CFG) const {
3083
+ llvm_unreachable (" Mico32 does not support varargs" );
3084
+ return 0 ;
3085
+ }
3086
+
3000
3087
3001
3088
// ===----------------------------------------------------------------------===//
3002
3089
// MIPS ABI Implementation. This works for both little-endian and
0 commit comments