Skip to content

Commit 56b5111

Browse files
authored
[CIR] Backport CIRAttrConstraints definitions (#1723)
1 parent 4b45e3b commit 56b5111

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file defines the CIR dialect attributes constraints.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef CLANG_CIR_DIALECT_IR_CIRATTRCONSTRAINTS_TD
14+
#define CLANG_CIR_DIALECT_IR_CIRATTRCONSTRAINTS_TD
15+
16+
include "mlir/IR/CommonAttrConstraints.td"
17+
18+
class CIR_IsAttrPred<code attr> : CPred<"::mlir::isa<" # attr # ">($_self)">;
19+
20+
class CIR_AttrConstraint<code attr, string summary = "">
21+
: Attr<CIR_IsAttrPred<attr>, summary>;
22+
23+
//===----------------------------------------------------------------------===//
24+
// IntAttr constraints
25+
//===----------------------------------------------------------------------===//
26+
27+
def CIR_AnyIntAttr : CIR_AttrConstraint<"::cir::IntAttr", "integer attribute">;
28+
29+
//===----------------------------------------------------------------------===//
30+
// FPAttr constraints
31+
//===----------------------------------------------------------------------===//
32+
33+
def CIR_AnyFPAttr : CIR_AttrConstraint<"::cir::FPAttr",
34+
"floating-point attribute">;
35+
36+
def CIR_AnyIntOrFloatAttr : AnyAttrOf<[CIR_AnyIntAttr, CIR_AnyFPAttr],
37+
"integer or floating point type"> {
38+
string cppType = "::mlir::TypedAttr";
39+
}
40+
41+
//===----------------------------------------------------------------------===//
42+
// ArrayAttr constraints
43+
//===----------------------------------------------------------------------===//
44+
45+
def CIR_IntArrayAttr : TypedArrayAttrBase<CIR_AnyIntAttr,
46+
"integer array attribute">;
47+
48+
#endif // CLANG_CIR_DIALECT_IR_CIRATTRCONSTRAINTS_TD

clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include "mlir/IR/BuiltinAttributeInterfaces.td"
1717
include "mlir/IR/EnumAttr.td"
1818

1919
include "clang/CIR/Dialect/IR/CIRDialect.td"
20+
include "clang/CIR/Dialect/IR/CIRAttrConstraints.td"
2021

2122
include "clang/CIR/Interfaces/ASTAttrInterfaces.td"
2223

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ include "clang/CIR/Dialect/IR/CIRDialect.td"
1818
include "clang/CIR/Dialect/IR/CIRTypes.td"
1919
include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
2020
include "clang/CIR/Dialect/IR/CIRAttrs.td"
21+
include "clang/CIR/Dialect/IR/CIRAttrConstraints.td"
22+
2123

2224
include "clang/CIR/Interfaces/ASTAttrInterfaces.td"
2325
include "clang/CIR/Interfaces/CIROpInterfaces.td"

0 commit comments

Comments
 (0)