[flang-commits] [llvm] [clang] [compiler-rt] [flang] [clang-tools-extra] [clang] Add support for new loop attribute [[clang::code_align()]] (PR #70762)
Erich Keane via flang-commits
flang-commits at lists.llvm.org
Wed Nov 15 07:36:02 PST 2023
================
@@ -322,6 +322,81 @@ static Attr *handleUnlikely(Sema &S, Stmt *St, const ParsedAttr &A,
return ::new (S.Context) UnlikelyAttr(S.Context, A);
}
+CodeAlignAttr *Sema::BuildCodeAlignAttr(const AttributeCommonInfo &CI,
+ Expr *E) {
+ if (!E->isValueDependent()) {
+ llvm::APSInt ArgVal;
+ ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
+ if (Res.isInvalid())
+ return nullptr;
+ E = Res.get();
+
+ // This attribute requires an integer argument which is a constant power of
+ // two between 1 and 4096 inclusive.
+ if (ArgVal < CodeAlignAttr::MinimumAlignment ||
+ (ArgVal < CodeAlignAttr::MaximumAlignment && !ArgVal.isPowerOf2())) {
+ Diag(CI.getLoc(), diag::err_attribute_power_of_two_in_range)
+ << CI << CodeAlignAttr::MinimumAlignment
+ << CodeAlignAttr::MaximumAlignment << ArgVal.getSExtValue();
+ return nullptr;
+ }
+
+ if (ArgVal > CodeAlignAttr::MaximumAlignment) {
+ if (ArgVal > std::numeric_limits<int32_t>::max() &&
----------------
erichkeane wrote:
`https://llvm.org/doxygen/classllvm_1_1APInt.html#ae30d62aebec681aceb655de2489f12ba`
https://github.com/llvm/llvm-project/pull/70762
More information about the flang-commits
mailing list