@@ -3130,57 +3130,14 @@ def LoopHint : Attr {
31303130 llvm_unreachable("Unhandled LoopHint option.");
31313131 }
31323132
3133- void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3134- unsigned SpellingIndex = getAttributeSpellingListIndex();
3135- // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
3136- // "nounroll" is already emitted as the pragma name.
3137- if (SpellingIndex == Pragma_nounroll || SpellingIndex == Pragma_nounroll_and_jam)
3138- return;
3139- else if (SpellingIndex == Pragma_unroll || SpellingIndex == Pragma_unroll_and_jam) {
3140- OS << ' ' << getValueString(Policy);
3141- return;
3142- }
3143-
3144- assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
3145- OS << ' ' << getOptionName(option) << getValueString(Policy);
3146- }
3133+ void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const;
31473134
31483135 // Return a string containing the loop hint argument including the
31493136 // enclosing parentheses.
3150- std::string getValueString(const PrintingPolicy &Policy) const {
3151- std::string ValueName;
3152- llvm::raw_string_ostream OS(ValueName);
3153- OS << "(";
3154- if (state == Numeric)
3155- value->printPretty(OS, nullptr, Policy);
3156- else if (state == Enable)
3157- OS << "enable";
3158- else if (state == Full)
3159- OS << "full";
3160- else if (state == AssumeSafety)
3161- OS << "assume_safety";
3162- else
3163- OS << "disable";
3164- OS << ")";
3165- return OS.str();
3166- }
3137+ std::string getValueString(const PrintingPolicy &Policy) const;
31673138
31683139 // Return a string suitable for identifying this attribute in diagnostics.
3169- std::string getDiagnosticName(const PrintingPolicy &Policy) const {
3170- unsigned SpellingIndex = getAttributeSpellingListIndex();
3171- if (SpellingIndex == Pragma_nounroll)
3172- return "#pragma nounroll";
3173- else if (SpellingIndex == Pragma_unroll)
3174- return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
3175- else if (SpellingIndex == Pragma_nounroll_and_jam)
3176- return "#pragma nounroll_and_jam";
3177- else if (SpellingIndex == Pragma_unroll_and_jam)
3178- return "#pragma unroll_and_jam" +
3179- (option == UnrollAndJamCount ? getValueString(Policy) : "");
3180-
3181- assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
3182- return getOptionName(option) + getValueString(Policy);
3183- }
3140+ std::string getDiagnosticName(const PrintingPolicy &Policy) const;
31843141 }];
31853142
31863143 let Documentation = [LoopHintDocs, UnrollHintDocs];
@@ -3240,53 +3197,7 @@ def OMPDeclareSimdDecl : Attr {
32403197 ];
32413198 let AdditionalMembers = [{
32423199 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
3243- const {
3244- if (getBranchState() != BS_Undefined)
3245- OS << ' ' << ConvertBranchStateTyToStr(getBranchState());
3246- if (auto *E = getSimdlen()) {
3247- OS << " simdlen(";
3248- E->printPretty(OS, nullptr, Policy);
3249- OS << ")";
3250- }
3251- if (uniforms_size() > 0) {
3252- OS << " uniform";
3253- StringRef Sep = "(";
3254- for (auto *E : uniforms()) {
3255- OS << Sep;
3256- E->printPretty(OS, nullptr, Policy);
3257- Sep = ", ";
3258- }
3259- OS << ")";
3260- }
3261- alignments_iterator NI = alignments_begin();
3262- for (auto *E : aligneds()) {
3263- OS << " aligned(";
3264- E->printPretty(OS, nullptr, Policy);
3265- if (*NI) {
3266- OS << ": ";
3267- (*NI)->printPretty(OS, nullptr, Policy);
3268- }
3269- OS << ")";
3270- ++NI;
3271- }
3272- steps_iterator I = steps_begin();
3273- modifiers_iterator MI = modifiers_begin();
3274- for (auto *E : linears()) {
3275- OS << " linear(";
3276- if (*MI != OMPC_LINEAR_unknown)
3277- OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
3278- E->printPretty(OS, nullptr, Policy);
3279- if (*MI != OMPC_LINEAR_unknown)
3280- OS << ")";
3281- if (*I) {
3282- OS << ": ";
3283- (*I)->printPretty(OS, nullptr, Policy);
3284- }
3285- OS << ")";
3286- ++I;
3287- ++MI;
3288- }
3289- }
3200+ const;
32903201 }];
32913202}
32923203
@@ -3304,30 +3215,10 @@ def OMPDeclareTargetDecl : InheritableAttr {
33043215 [ "DT_Host", "DT_NoHost", "DT_Any" ]>
33053216 ];
33063217 let AdditionalMembers = [{
3307- void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3308- // Use fake syntax because it is for testing and debugging purpose only.
3309- if (getDevType() != DT_Any)
3310- OS << " device_type(" << ConvertDevTypeTyToStr(getDevType()) << ")";
3311- if (getMapType() != MT_To)
3312- OS << ' ' << ConvertMapTypeTyToStr(getMapType());
3313- }
3218+ void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const;
33143219 static llvm::Optional<MapTypeTy>
3315- isDeclareTargetDeclaration(const ValueDecl *VD) {
3316- if (!VD->hasAttrs())
3317- return llvm::None;
3318- if (const auto *Attr = VD->getAttr<OMPDeclareTargetDeclAttr>())
3319- return Attr->getMapType();
3320-
3321- return llvm::None;
3322- }
3323- static llvm::Optional<DevTypeTy> getDeviceType(const ValueDecl *VD) {
3324- if (!VD->hasAttrs())
3325- return llvm::None;
3326- if (const auto *Attr = VD->getAttr<OMPDeclareTargetDeclAttr>())
3327- return Attr->getDevType();
3328-
3329- return llvm::None;
3330- }
3220+ isDeclareTargetDeclaration(const ValueDecl *VD);
3221+ static llvm::Optional<DevTypeTy> getDeviceType(const ValueDecl *VD);
33313222 }];
33323223}
33333224
@@ -3368,16 +3259,7 @@ def OMPDeclareVariant : InheritableAttr {
33683259 let AdditionalMembers = [{
33693260 OMPTraitInfo &getTraitInfo() { return traitInfos; }
33703261 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
3371- const {
3372- if (const Expr *E = getVariantFuncRef()) {
3373- OS << "(";
3374- E->printPretty(OS, nullptr, Policy);
3375- OS << ")";
3376- }
3377- OS << " match(";
3378- traitInfos.print(OS, Policy);
3379- OS << ")";
3380- }
3262+ const;
33813263 }];
33823264}
33833265
0 commit comments