|
15 | 15 |
|
16 | 16 | include "mlir/IR/BuiltinAttributeInterfaces.td"
|
17 | 17 | include "mlir/IR/EnumAttr.td"
|
| 18 | + |
18 | 19 | include "clang/CIR/Dialect/IR/CIRDialect.td"
|
19 | 20 |
|
| 21 | +include "clang/CIR/Interfaces/ASTAttrInterfaces.td" |
| 22 | + |
20 | 23 | //===----------------------------------------------------------------------===//
|
21 | 24 | // CIR Attrs
|
22 | 25 | //===----------------------------------------------------------------------===//
|
@@ -394,12 +397,55 @@ class ASTDecl<string name, string prefix, list<Trait> traits = []>
|
394 | 397 |
|
395 | 398 | // Enable verifier.
|
396 | 399 | let genVerifyDecl = 1;
|
| 400 | + |
| 401 | + let extraClassDefinition = [{ |
| 402 | + ::mlir::Attribute $cppClass::parse(::mlir::AsmParser &parser, |
| 403 | + ::mlir::Type type) { |
| 404 | + // We cannot really parse anything AST related at this point |
| 405 | + // since we have no serialization/JSON story. |
| 406 | + return $cppClass::get(parser.getContext(), nullptr); |
| 407 | + } |
| 408 | + |
| 409 | + void $cppClass::print(::mlir::AsmPrinter &printer) const { |
| 410 | + // Nothing to print besides the mnemonics. |
| 411 | + } |
| 412 | + |
| 413 | + LogicalResult $cppClass::verify( |
| 414 | + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, |
| 415 | + }] # clang_name # [{ decl) { |
| 416 | + return success(); |
| 417 | + } |
| 418 | + }]; |
397 | 419 | }
|
398 | 420 |
|
399 |
| -def ASTFunctionDeclAttr : ASTDecl<"FunctionDecl", "fndecl">; |
400 |
| -def ASTVarDeclAttr : ASTDecl<"VarDecl", "vardecl">; |
401 |
| -def ASTRecordDeclAttr : ASTDecl<"RecordDecl", "recdecl">; |
| 421 | +def ASTDeclAttr : ASTDecl<"Decl", "decl", [ASTDeclInterface]>; |
| 422 | + |
| 423 | +def ASTFunctionDeclAttr : ASTDecl<"FunctionDecl", "function.decl", |
| 424 | + [ASTFunctionDeclInterface]>; |
| 425 | + |
| 426 | +def ASTCXXMethodDeclAttr : ASTDecl<"CXXMethodDecl", "cxxmethod.decl", |
| 427 | + [ASTCXXMethodDeclInterface]>; |
| 428 | + |
| 429 | +def ASTCXXConstructorDeclAttr : ASTDecl<"CXXConstructorDecl", |
| 430 | + "cxxconstructor.decl", [ASTCXXConstructorDeclInterface]>; |
| 431 | + |
| 432 | +def ASTCXXConversionDeclAttr : ASTDecl<"CXXConversionDecl", |
| 433 | + "cxxconversion.decl", [ASTCXXConversionDeclInterface]>; |
| 434 | + |
| 435 | +def ASTCXXDestructorDeclAttr : ASTDecl<"CXXDestructorDecl", |
| 436 | + "cxxdestructor.decl", [ASTCXXDestructorDeclInterface]>; |
| 437 | + |
| 438 | +def ASTVarDeclAttr : ASTDecl<"VarDecl", "var.decl", |
| 439 | + [ASTVarDeclInterface]>; |
| 440 | + |
| 441 | +def ASTTypeDeclAttr: ASTDecl<"TypeDecl", "type.decl", |
| 442 | + [ASTTypeDeclInterface]>; |
| 443 | + |
| 444 | +def ASTTagDeclAttr : ASTDecl<"TagDecl", "tag.decl", |
| 445 | + [ASTTagDeclInterface]>; |
402 | 446 |
|
| 447 | +def ASTRecordDeclAttr : ASTDecl<"RecordDecl", "record.decl", |
| 448 | + [ASTRecordDeclInterface]>; |
403 | 449 |
|
404 | 450 | //===----------------------------------------------------------------------===//
|
405 | 451 | // ExtraFuncAttr
|
|
0 commit comments