diff --git a/src/mapleall/maple_ir/include/all_attributes.def b/src/mapleall/maple_ir/include/all_attributes.def index 3c81c255069993125598dcc37bcee528f4b47739..7c10fae96a9b925b3c22a424ee496bcb23f94d28 100644 --- a/src/mapleall/maple_ir/include/all_attributes.def +++ b/src/mapleall/maple_ir/include/all_attributes.def @@ -77,3 +77,6 @@ ATTR(localrefvar) ATTR(rcunownedthis) #endif +#ifdef FUNC_ATTR + ATTR(firstarg_return) +#endif diff --git a/src/mapleall/maple_ir/include/mir_function.h b/src/mapleall/maple_ir/include/mir_function.h index bdb9b167334617d78eceb0f3054cecfafb17ca7b..8e2defaa1dd29afdd9659328ec22922fd4433d14 100644 --- a/src/mapleall/maple_ir/include/mir_function.h +++ b/src/mapleall/maple_ir/include/mir_function.h @@ -204,6 +204,14 @@ class MIRFunction { MIRSymbol *GetLocalOrGlobalSymbol(const StIdx &idx, bool checkFirst = false); void SetAttrsFromSe(uint8 specialEffect); + + FuncAttrs GetAttrs() const { + return funcAttrs; + } + void SetAttrs(FuncAttrs attr) { + funcAttrs = attr; + } + bool GetAttr(FuncAttrKind attrKind) const { return funcAttrs.GetAttr(attrKind); } @@ -290,6 +298,10 @@ class MIRFunction { return funcAttrs.GetAttr(FUNCATTR_pure); } + bool IsFirstArgReturn() const { + return funcAttrs.GetAttr(FUNCATTR_firstarg_return); + } + void SetVarArgs() { funcAttrs.SetAttr(FUNCATTR_varargs); } @@ -326,6 +338,10 @@ class MIRFunction { funcAttrs.SetAttr(FUNCATTR_pure); } + void SetFirstArgReturn() { + funcAttrs.SetAttr(FUNCATTR_firstarg_return); + } + void UnsetNoDefArgEffect() { funcAttrs.SetAttr(FUNCATTR_nodefargeffect, true); } @@ -371,6 +387,11 @@ class MIRFunction { void SetNoReturn(); bool NeverReturns() const; + void SetHasSetjmp(); + bool HasSetjmp() const; + + void SetReturnStruct(MIRType *retType); + bool IsEmpty() const; bool IsClinit() const; uint32 GetInfo(GStrIdx strIdx) const; diff --git a/src/mapleall/maple_ir/src/mir_function.cpp b/src/mapleall/maple_ir/src/mir_function.cpp index 1ea335b8a482e1b2d31eab5eba7782d91d3b3a7c..aff5fa9ebf2f8433cf51c056e3094163585179b3 100644 --- a/src/mapleall/maple_ir/src/mir_function.cpp +++ b/src/mapleall/maple_ir/src/mir_function.cpp @@ -30,6 +30,7 @@ enum FuncProp : uint32_t { // than once per function since they // can only be printed at the beginning of a block kFuncPropNeverReturn = 1U << 4, // the function when called never returns + kFuncPropHasSetjmp = 1U << 5, // the function contains call to setjmp }; } // namespace @@ -150,6 +151,20 @@ void MIRFunction::SetReturnStruct(MIRType &retType) { flag |= kFuncPropRetStruct; } } +void MIRFunction::SetReturnStruct(MIRType *retType) { + switch (retType->GetKind()) { + case kTypeUnion: + case kTypeStruct: + case kTypeStructIncomplete: + case kTypeClass: + case kTypeClassIncomplete: + case kTypeInterface: + case kTypeInterfaceIncomplete: + flag |= kFuncPropRetStruct; + break; + default:; + } +} bool MIRFunction::IsUserFunc() const { return flag & kFuncPropUserFunc; @@ -175,6 +190,14 @@ bool MIRFunction::NeverReturns() const { return flag & kFuncPropNeverReturn; } +void MIRFunction::SetHasSetjmp() { + flag |= kFuncPropHasSetjmp; +} + +bool MIRFunction::HasSetjmp() const { + return flag & kFuncPropHasSetjmp; +} + void MIRFunction::SetAttrsFromSe(uint8 specialEffect) { // NoPrivateDefEffect if ((specialEffect & kDefEffect) == kDefEffect) {