MLIR-AIE 1.4.6.dev
TargetInfo.h
Go to the documentation of this file.
1//===- TargetInfo.h - AIEVec target parsing ---------------------*- C++ -*-===//
2//
3// Copyright (C) 2026 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7//
8// Parsing of the `aie-target` option shared by the AIEVec passes.
9//
10//===----------------------------------------------------------------------===//
11
12#ifndef AIE_DIALECT_AIEVEC_UTILS_TARGETINFO_H
13#define AIE_DIALECT_AIEVEC_UTILS_TARGETINFO_H
14
15#include "llvm/ADT/StringRef.h"
16
17#include <optional>
18
19namespace mlir {
20class Operation;
21} // namespace mlir
22
23namespace xilinx::aievec {
24
25// Named apart from xilinx::AIE::AIEArch, which several AIEVec sources also see.
26enum class AIEVecArch { AIE1, AIE2, AIE2P, AIE2PS };
27
30
31 bool isAIE1() const { return arch == AIEVecArch::AIE1; }
32 bool isAIE2() const { return arch == AIEVecArch::AIE2; }
33 bool isAIE2P() const { return arch == AIEVecArch::AIE2P; }
34 bool isAIE2PS() const { return arch == AIEVecArch::AIE2PS; }
35
36 // Whether vector-to-AIEVec conversion and AIEVec-to-LLVM lowering exist for
37 // this target. AIE2PS is accepted as a target, but has neither.
38 bool hasAIEVecLowering() const { return !isAIE2PS(); }
39};
40
41// Accepts "" and "aie" (AIE1), "aieml" and "aie2" (AIE2), "aie2p" and "aie2ps".
42// Returns std::nullopt for any other spelling.
43std::optional<AIEVecTargetInfo> parseAIEVecTarget(llvm::StringRef spelling);
44
45// As above, but also reports an unknown spelling as an error on `op`.
46std::optional<AIEVecTargetInfo> parseAIEVecTarget(llvm::StringRef spelling,
47 mlir::Operation *op);
48
49// As above, and also reports an error on `op` if the target has no AIEVec
50// lowering. Used by the vector-to-AIEVec passes.
51std::optional<AIEVecTargetInfo>
52parseAIEVecLoweringTarget(llvm::StringRef spelling, mlir::Operation *op);
53
54llvm::StringRef getAIEVecTargetName(AIEVecTargetInfo info);
55
56} // namespace xilinx::aievec
57
58#endif // AIE_DIALECT_AIEVEC_UTILS_TARGETINFO_H
llvm::StringRef getAIEVecTargetName(AIEVecTargetInfo info)
std::optional< AIEVecTargetInfo > parseAIEVecLoweringTarget(llvm::StringRef spelling, mlir::Operation *op)
std::optional< AIEVecTargetInfo > parseAIEVecTarget(llvm::StringRef spelling)