Skip to content

Conversation

badumbatish
Copy link
Contributor

Part of #1912

This PR only fixes 1 file. Also added a CI file to see if it'd run correctly

Copy link
Collaborator

@xlauko xlauko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to split the PR, first setup an action and then add changes incrementally always checking it passes the new action.

The first one should have tag [Github][CIR]

@badumbatish badumbatish changed the title [CIR] [NFC] Fix formatting style in FrontendAction [1/N] [Github] [CIR] Add CI/CD for clang tidy [1/N] Sep 24, 2025
@badumbatish
Copy link
Contributor Author

badumbatish commented Sep 26, 2025

about the hacky ninja -C build_pilot $(ninja -C build_pilot -t targets all | grep IncGen | sed 's/:.*//') clang-tablegen-targets, the reason is that we don't make these IncGen's in CIR be dependencies on mlir-headers via add_dependencies(mlir-headers ...).

For example, in clang/include/clang/CIR/Dialect/IR/CMakeLists.txt, MLIRCIREnumsGen is not added to mlir-headers' dependencies so when we build the mlir-headers target, clang-tidy's reporting compiler error.

# This replicates part of the add_mlir_dialect cmake function from MLIR that
# cannot be used here. This happens because it expects to be run inside MLIR
# directory which is not the case for CIR (and also FIR, both have similar
# workarounds).

# Equivalent to add_mlir_dialect(CIROps cir)
set(LLVM_TARGET_DEFINITIONS CIROps.td)
mlir_tablegen(CIROps.h.inc -gen-op-decls)
mlir_tablegen(CIROps.cpp.inc -gen-op-defs)
mlir_tablegen(CIROpsTypes.h.inc -gen-typedef-decls)
mlir_tablegen(CIROpsTypes.cpp.inc -gen-typedef-defs)
mlir_tablegen(CIROpsDialect.h.inc -gen-dialect-decls)
mlir_tablegen(CIROpsDialect.cpp.inc -gen-dialect-defs)
add_public_tablegen_target(MLIRCIROpsIncGen)
add_dependencies(mlir-headers MLIRCIROpsIncGen)

# Equivalent to add_mlir_doc
add_clang_mlir_doc(CIROps CIROps Dialects/ -gen-op-doc)
add_clang_mlir_doc(CIRAttrs CIRAttrs Dialects/ -gen-attrdef-doc)
add_clang_mlir_doc(CIRTypes CIRTypes Dialects/ -gen-typedef-doc)

# Generate extra headers for custom enum and attrs.
mlir_tablegen(CIROpsEnums.h.inc -gen-enum-decls)
mlir_tablegen(CIROpsEnums.cpp.inc -gen-enum-defs)
mlir_tablegen(CIROpsStructs.h.inc -gen-attrdef-decls)
mlir_tablegen(CIROpsStructs.cpp.inc -gen-attrdef-defs)
mlir_tablegen(CIROpsAttributes.h.inc -gen-attrdef-decls)
mlir_tablegen(CIROpsAttributes.cpp.inc -gen-attrdef-defs)
add_public_tablegen_target(MLIRCIREnumsGen)

clang_tablegen(CIRBuiltinsLowering.inc -gen-cir-builtins-lowering
               SOURCE CIROps.td
               TARGET CIRBuiltinsLowering)

set(LLVM_TARGET_DEFINITIONS CIRTypeConstraints.td)
mlir_tablegen(CIRTypeConstraints.h.inc -gen-type-constraint-decls)
mlir_tablegen(CIRTypeConstraints.cpp.inc -gen-type-constraint-defs)
add_public_tablegen_target(MLIRCIRTypeConstraintsIncGen)
add_dependencies(mlir-headers MLIRCIRTypeConstraintsIncGen)

if we depend on the ninja check-clang-cir job it wouldn't be much of a problem, but if we're aiming for a separate CI/CD completely then we probably should make a few PR to address these, so that we don't end up with the hacky ninja build command

@bcardosolopes
Copy link
Member

the reason is that we don't make these IncGen's in CIR be dependencies on mlir-headers via add_dependencies(mlir-headers ...).

That was a great catch, fixing this dependency sounds like the way to go!

@bcardosolopes bcardosolopes changed the title [Github] [CIR] Add CI/CD for clang tidy [1/N] [Github][CIR] Add CI/CD for clang tidy [1/N] Oct 3, 2025
bcardosolopes pushed a commit that referenced this pull request Oct 9, 2025
… mlir-headers dependencies (#1928)

Similar to #1927 , this allows generation of the missing mlir tablegen
targets without going through
```
$(ninja -C build_pilot -t targets all | grep IncGen | sed 's/:.*//')
```

Helpful to #1917
@badumbatish
Copy link
Contributor Author

I've included the two other PRs into this one, we can now use mlir-headers. Run time is 11 minutes but can be reduced w/ ccache. Please let me know if you'd like me to add ccache to this PR (or another one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants