38 #include "mlir/Dialect/ArmSME/Transforms/PassesEnums.cpp.inc"
42 #define DEBUG_TYPE "enable-arm-streaming"
46 #define GEN_PASS_DEF_ENABLEARMSTREAMING
47 #include "mlir/Dialect/ArmSME/Transforms/Passes.h.inc"
55 constexpr StringLiteral
56 kEnableArmStreamingIgnoreAttr(
"enable_arm_streaming_ignore");
58 struct EnableArmStreamingPass
59 :
public arm_sme::impl::EnableArmStreamingBase<EnableArmStreamingPass> {
60 EnableArmStreamingPass(ArmStreamingMode streamingMode, ArmZaMode zaMode,
61 bool onlyIfRequiredByOps) {
62 this->streamingMode = streamingMode;
63 this->zaMode = zaMode;
64 this->onlyIfRequiredByOps = onlyIfRequiredByOps;
66 void runOnOperation()
override {
67 auto op = getOperation();
69 if (onlyIfRequiredByOps) {
70 bool foundTileOp =
false;
72 if (llvm::isa<ArmSMETileOpInterface>(op)) {
82 if (op->
getAttr(kEnableArmStreamingIgnoreAttr) ||
83 streamingMode == ArmStreamingMode::Disabled)
88 op->
setAttr(stringifyArmStreamingMode(streamingMode), unitAttr);
94 if (zaMode != ArmZaMode::Disabled)
95 op->
setAttr(stringifyArmZaMode(zaMode), unitAttr);
101 const ArmStreamingMode streamingMode,
const ArmZaMode zaMode,
102 bool onlyIfRequiredByOps) {
103 return std::make_unique<EnableArmStreamingPass>(streamingMode, zaMode,
104 onlyIfRequiredByOps);
static MLIRContext * getContext(OpFoldResult val)
Operation is the basic unit of execution within MLIR.
Attribute getAttr(StringAttr name)
Return the specified attribute if present, null otherwise.
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > walk(FnT &&callback)
Walk the operation by calling the callback for each nested operation (including this one),...
void setAttr(StringAttr name, Attribute value)
If the an attribute exists with the specified name, change it to the new value.
static WalkResult advance()
static WalkResult interrupt()
std::unique_ptr< Pass > createEnableArmStreamingPass(const ArmStreamingMode=ArmStreamingMode::Streaming, const ArmZaMode=ArmZaMode::Disabled, bool onlyIfRequiredByOps=false)
Pass to enable Armv9 Streaming SVE mode.
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...