[llvm] [Attributor] Pack out arguments into a struct (PR #119267)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 26 05:02:02 PST 2024
================
@@ -6469,6 +6469,54 @@ struct AADenormalFPMath
static const char ID;
};
+/// An abstract attribute for converting out arguments into struct elements.
+struct AAConvertOutArgument
+ : public StateWrapper<BooleanState, AbstractAttribute> {
+ using Base = StateWrapper<BooleanState, AbstractAttribute>;
+
+ AAConvertOutArgument(const IRPosition &IRP, Attributor &A) : Base(IRP) {}
+
+ /// Create an abstract attribute view for the position \p IRP.
+ static AAConvertOutArgument &createForPosition(const IRPosition &IRP,
+ Attributor &A);
+
+ /// See AbstractAttribute::getName()
+ const std::string getName() const override { return "AAConvertOutArgument"; }
+
+ /// Return true if convertible is assumed.
+ bool isAssumedConvertible() const { return getAssumed(); }
+
+ /// Return true if convertible is known.
+ bool isKnownConvertible() const { return getKnown(); }
+
+ /// See AbstractAttribute::getIdAddr()
+ const char *getIdAddr() const override { return &ID; }
+
+ /// This function should return true if the type of the \p AA is
+ /// AADenormalFPMath.
+ static bool classof(const AbstractAttribute *AA) {
+ return (AA->getIdAddr() == &ID);
+ }
+
+ /// Unique ID (due to the unique address)
+ static const char ID;
+
+protected:
+ static bool isEligibleArgumentType(Type *Ty) { return Ty->isPointerTy(); }
+
+ static bool isEligibleArgument(const Argument &Arg, Attributor &A,
+ const AbstractAttribute &AA) {
+ if (!isEligibleArgumentType(Arg.getType()))
----------------
arsenm wrote:
Should also check the disallowed argument attributes like byval
https://github.com/llvm/llvm-project/pull/119267
More information about the llvm-commits
mailing list