Skip to content

[CIR] Untie Type and Attribute definitions #1727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_DIALECT_CIR_IR_CIRATTRS_H_
#define MLIR_DIALECT_CIR_IR_CIRATTRS_H_

#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
#include "clang/CIR/Dialect/IR/CIRTypes.h"
#ifndef CLANG_CIR_DIALECT_IR_CIRATTRS_H
#define CLANG_CIR_DIALECT_IR_CIRATTRS_H

#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinAttributeInterfaces.h"

#include "llvm/ADT/SmallVector.h"

#include "clang/CIR/Dialect/IR/CIROpsEnums.h"

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

namespace clang {
class FunctionDecl;
class VarDecl;
class RecordDecl;
class VarDecl;
} // namespace clang

namespace cir {
class ArrayType;
class RecordType;
class BoolType;
class ComplexType;
class DataMemberType;
class IntType;
class MethodType;
class PointerType;
class RecordType;
class VectorType;
} // namespace cir

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

#endif // MLIR_DIALECT_CIR_IR_CIRATTRS_H_
#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_H
24 changes: 17 additions & 7 deletions clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -199,29 +199,39 @@ def CIR_TypeSizeInfoAttr : CIR_Attr<"TypeSizeInfo", "type_size_info"> {
}];

let extraClassDeclaration = [{
unsigned getPointerSize() const { return getSizeTSize(); }
unsigned getPointerSize() const;
mlir::Type getCharType(mlir::MLIRContext *ctx) const;
mlir::Type getUCharType(mlir::MLIRContext *ctx) const;
mlir::Type getIntType(mlir::MLIRContext *ctx) const;
mlir::Type getUIntType(mlir::MLIRContext *ctx) const;
mlir::Type getSizeType(mlir::MLIRContext *ctx) const;
mlir::Type getPtrDiffType(mlir::MLIRContext *ctx) const;
}];

let extraClassDefinition = [{
unsigned $cppClass::getPointerSize() const { return getSizeTSize(); }

mlir::Type getCharType(mlir::MLIRContext *ctx) const {
mlir::Type $cppClass::getCharType(mlir::MLIRContext *ctx) const {
return cir::IntType::get(ctx, getCharSize(), /*signed=*/true);
}

mlir::Type getUCharType(mlir::MLIRContext *ctx) const {
mlir::Type $cppClass::getUCharType(mlir::MLIRContext *ctx) const {
return cir::IntType::get(ctx, getCharSize(), /*signed=*/false);
}

mlir::Type getIntType(mlir::MLIRContext *ctx) const {
mlir::Type $cppClass::getIntType(mlir::MLIRContext *ctx) const {
return cir::IntType::get(ctx, getIntSize(), /*signed=*/true);
}

mlir::Type getUIntType(mlir::MLIRContext *ctx) const {
mlir::Type $cppClass::getUIntType(mlir::MLIRContext *ctx) const {
return cir::IntType::get(ctx, getIntSize(), /*signed=*/false);
}

mlir::Type getSizeType(mlir::MLIRContext *ctx) const {
mlir::Type $cppClass::getSizeType(mlir::MLIRContext *ctx) const {
return cir::IntType::get(ctx, getSizeTSize(), /*signed=*/false);
}

mlir::Type getPtrDiffType(mlir::MLIRContext *ctx) const {
mlir::Type $cppClass::getPtrDiffType(mlir::MLIRContext *ctx) const {
return cir::IntType::get(ctx, getSizeTSize(), /*signed=*/true);
}
}];
Expand Down
Loading