Skip to content

Commit a6b4aea

Browse files
xlaukolanza
authored andcommitted
[CIR] Untie Type and Attribute definitions (llvm#1727)
This will allow to use Attributes and Types together in tablegen without inducing cyclic dependency.
1 parent 4e600d4 commit a6b4aea

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef MLIR_DIALECT_CIR_IR_CIRATTRS_H_
14-
#define MLIR_DIALECT_CIR_IR_CIRATTRS_H_
15-
16-
#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
17-
#include "clang/CIR/Dialect/IR/CIRTypes.h"
13+
#ifndef CLANG_CIR_DIALECT_IR_CIRATTRS_H
14+
#define CLANG_CIR_DIALECT_IR_CIRATTRS_H
1815

1916
#include "mlir/IR/Attributes.h"
2017
#include "mlir/IR/BuiltinAttributeInterfaces.h"
2118

22-
#include "llvm/ADT/SmallVector.h"
23-
2419
#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
2520

2621
#include "clang/CIR/Interfaces/ASTAttrInterfaces.h"
@@ -32,17 +27,23 @@
3227

3328
namespace clang {
3429
class FunctionDecl;
35-
class VarDecl;
3630
class RecordDecl;
31+
class VarDecl;
3732
} // namespace clang
3833

3934
namespace cir {
4035
class ArrayType;
41-
class RecordType;
4236
class BoolType;
37+
class ComplexType;
38+
class DataMemberType;
39+
class IntType;
40+
class MethodType;
41+
class PointerType;
42+
class RecordType;
43+
class VectorType;
4344
} // namespace cir
4445

4546
#define GET_ATTRDEF_CLASSES
4647
#include "clang/CIR/Dialect/IR/CIROpsAttributes.h.inc"
4748

48-
#endif // MLIR_DIALECT_CIR_IR_CIRATTRS_H_
49+
#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_H

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,29 +199,39 @@ def CIR_TypeSizeInfoAttr : CIR_Attr<"TypeSizeInfo", "type_size_info"> {
199199
}];
200200

201201
let extraClassDeclaration = [{
202-
unsigned getPointerSize() const { return getSizeTSize(); }
202+
unsigned getPointerSize() const;
203+
mlir::Type getCharType(mlir::MLIRContext *ctx) const;
204+
mlir::Type getUCharType(mlir::MLIRContext *ctx) const;
205+
mlir::Type getIntType(mlir::MLIRContext *ctx) const;
206+
mlir::Type getUIntType(mlir::MLIRContext *ctx) const;
207+
mlir::Type getSizeType(mlir::MLIRContext *ctx) const;
208+
mlir::Type getPtrDiffType(mlir::MLIRContext *ctx) const;
209+
}];
210+
211+
let extraClassDefinition = [{
212+
unsigned $cppClass::getPointerSize() const { return getSizeTSize(); }
203213

204-
mlir::Type getCharType(mlir::MLIRContext *ctx) const {
214+
mlir::Type $cppClass::getCharType(mlir::MLIRContext *ctx) const {
205215
return cir::IntType::get(ctx, getCharSize(), /*signed=*/true);
206216
}
207217

208-
mlir::Type getUCharType(mlir::MLIRContext *ctx) const {
218+
mlir::Type $cppClass::getUCharType(mlir::MLIRContext *ctx) const {
209219
return cir::IntType::get(ctx, getCharSize(), /*signed=*/false);
210220
}
211221

212-
mlir::Type getIntType(mlir::MLIRContext *ctx) const {
222+
mlir::Type $cppClass::getIntType(mlir::MLIRContext *ctx) const {
213223
return cir::IntType::get(ctx, getIntSize(), /*signed=*/true);
214224
}
215225

216-
mlir::Type getUIntType(mlir::MLIRContext *ctx) const {
226+
mlir::Type $cppClass::getUIntType(mlir::MLIRContext *ctx) const {
217227
return cir::IntType::get(ctx, getIntSize(), /*signed=*/false);
218228
}
219229

220-
mlir::Type getSizeType(mlir::MLIRContext *ctx) const {
230+
mlir::Type $cppClass::getSizeType(mlir::MLIRContext *ctx) const {
221231
return cir::IntType::get(ctx, getSizeTSize(), /*signed=*/false);
222232
}
223233

224-
mlir::Type getPtrDiffType(mlir::MLIRContext *ctx) const {
234+
mlir::Type $cppClass::getPtrDiffType(mlir::MLIRContext *ctx) const {
225235
return cir::IntType::get(ctx, getSizeTSize(), /*signed=*/true);
226236
}
227237
}];

0 commit comments

Comments
 (0)