diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h index 93a50cc8f3d6..f9bcf1c98311 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h @@ -33,7 +33,7 @@ #include "clang/CIR/Interfaces/ASTAttrInterfaces.h" #include "clang/CIR/Interfaces/CIROpInterfaces.h" -#include "clang/CIR/Interfaces/LoopOpInterface.h" +#include "clang/CIR/Interfaces/CIRLoopOpInterface.h" namespace mlir { namespace OpTrait { diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index cf9ac52f2436..dba7ffbdef3d 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -20,7 +20,7 @@ include "clang/CIR/Dialect/IR/CIRAttrs.td" include "clang/CIR/Interfaces/ASTAttrInterfaces.td" include "clang/CIR/Interfaces/CIROpInterfaces.td" -include "clang/CIR/Interfaces/LoopOpInterface.td" +include "clang/CIR/Interfaces/CIRLoopOpInterface.td" include "mlir/Interfaces/ControlFlowInterfaces.td" include "mlir/Interfaces/FunctionInterfaces.td" diff --git a/clang/include/clang/CIR/Interfaces/LoopOpInterface.h b/clang/include/clang/CIR/Interfaces/CIRLoopOpInterface.h similarity index 77% rename from clang/include/clang/CIR/Interfaces/LoopOpInterface.h rename to clang/include/clang/CIR/Interfaces/CIRLoopOpInterface.h index 96198c635aa9..2e8a0c8e8a94 100644 --- a/clang/include/clang/CIR/Interfaces/LoopOpInterface.h +++ b/clang/include/clang/CIR/Interfaces/CIRLoopOpInterface.h @@ -1,4 +1,4 @@ -//===- LoopOpInterface.h - Interface for CIR loop-like ops -----*- C++ -*-===// +//===- CIRLoopOpInterface.h - Interface for CIR loop-like ops --*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef CLANG_INTERFACES_CIR_LOOPOPINTERFACE_H_ -#define CLANG_INTERFACES_CIR_LOOPOPINTERFACE_H_ +#ifndef CLANG_INTERFACES_CIR_CIRLOOPOPINTERFACE_H_ +#define CLANG_INTERFACES_CIR_CIRLOOPOPINTERFACE_H_ #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/OpDefinition.h" @@ -31,6 +31,6 @@ ::mlir::LogicalResult verifyLoopOpInterface(::mlir::Operation *op); } // namespace mlir /// Include the tablegen'd interface declarations. -#include "clang/CIR/Interfaces/LoopOpInterface.h.inc" +#include "clang/CIR/Interfaces/CIRLoopOpInterface.h.inc" -#endif // CLANG_INTERFACES_CIR_LOOPOPINTERFACE_H_ +#endif // CLANG_INTERFACES_CIR_CIRLOOPOPINTERFACE_H_ diff --git a/clang/include/clang/CIR/Interfaces/LoopOpInterface.td b/clang/include/clang/CIR/Interfaces/CIRLoopOpInterface.td similarity index 93% rename from clang/include/clang/CIR/Interfaces/LoopOpInterface.td rename to clang/include/clang/CIR/Interfaces/CIRLoopOpInterface.td index ada6f8f86c5b..c2b871785ffd 100644 --- a/clang/include/clang/CIR/Interfaces/LoopOpInterface.td +++ b/clang/include/clang/CIR/Interfaces/CIRLoopOpInterface.td @@ -1,4 +1,4 @@ -//===- LoopOpInterface.td - Interface for CIR loop-like ops ----*- C++ -*-===// +//===- CIRLoopOpInterface.td - Interface for CIR loop-like ops -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,8 +6,8 @@ // //===---------------------------------------------------------------------===// -#ifndef CLANG_CIR_INTERFACES_LOOPOPINTERFACE -#define CLANG_CIR_INTERFACES_LOOPOPINTERFACE +#ifndef CLANG_CIR_INTERFACES_CIRLOOPOPINTERFACE +#define CLANG_CIR_INTERFACES_CIRLOOPOPINTERFACE include "mlir/IR/OpBase.td" include "mlir/Interfaces/ControlFlowInterfaces.td" @@ -97,4 +97,4 @@ def LoopOpInterface : OpInterface<"LoopOpInterface", [ }]; } -#endif // CLANG_CIR_INTERFACES_LOOPOPINTERFACE +#endif // CLANG_CIR_INTERFACES_CIRLOOPOPINTERFACE diff --git a/clang/include/clang/CIR/Interfaces/CMakeLists.txt b/clang/include/clang/CIR/Interfaces/CMakeLists.txt index 383eda4311a3..c7132abca833 100644 --- a/clang/include/clang/CIR/Interfaces/CMakeLists.txt +++ b/clang/include/clang/CIR/Interfaces/CMakeLists.txt @@ -22,4 +22,4 @@ endfunction() add_clang_mlir_attr_interface(ASTAttrInterfaces) add_clang_mlir_op_interface(CIROpInterfaces) -add_clang_mlir_op_interface(LoopOpInterface) +add_clang_mlir_op_interface(CIRLoopOpInterface) diff --git a/clang/lib/CIR/CodeGen/CMakeLists.txt b/clang/lib/CIR/CodeGen/CMakeLists.txt index 62df7a8d3d68..5af8f15aac34 100644 --- a/clang/lib/CIR/CodeGen/CMakeLists.txt +++ b/clang/lib/CIR/CodeGen/CMakeLists.txt @@ -41,6 +41,7 @@ add_clang_library(clangCIR MLIRCIROpsIncGen MLIRCIRASTAttrInterfacesIncGen MLIRCIROpInterfacesIncGen + MLIRCIRLoopOpInterfaceIncGen ${dialect_libs} LINK_LIBS diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 4530e7a7bcb9..24e8300e674f 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -14,7 +14,7 @@ #include "clang/CIR/Dialect/IR/CIRAttrs.h" #include "clang/CIR/Dialect/IR/CIROpsEnums.h" #include "clang/CIR/Dialect/IR/CIRTypes.h" -#include "clang/CIR/Interfaces/LoopOpInterface.h" +#include "clang/CIR/Interfaces/CIRLoopOpInterface.h" #include "llvm/Support/ErrorHandling.h" #include diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index b8cc5b84e93e..f4609c3aad32 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -11,6 +11,7 @@ add_clang_library(MLIRCIR MLIRSymbolInterfacesIncGen MLIRCIRASTAttrInterfacesIncGen MLIRCIROpInterfacesIncGen + MLIRCIRLoopOpInterfaceIncGen LINK_LIBS PUBLIC MLIRIR diff --git a/clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp b/clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp index 6a08f24466e6..e77a6bdf14b8 100644 --- a/clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp +++ b/clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp @@ -16,7 +16,7 @@ #include "clang/CIR/Dialect/IR/CIRDialect.h" #include "clang/CIR/Dialect/Passes.h" -#include "clang/CIR/Interfaces/LoopOpInterface.h" +#include "clang/CIR/Interfaces/CIRLoopOpInterface.h" #include "llvm/ADT/SetOperations.h" #include "llvm/ADT/SmallSet.h" diff --git a/clang/lib/CIR/FrontendAction/CMakeLists.txt b/clang/lib/CIR/FrontendAction/CMakeLists.txt index 31ca49fedf44..077bd733cbd8 100644 --- a/clang/lib/CIR/FrontendAction/CMakeLists.txt +++ b/clang/lib/CIR/FrontendAction/CMakeLists.txt @@ -12,6 +12,7 @@ add_clang_library(clangCIRFrontendAction MLIRCIROpsIncGen MLIRCIRASTAttrInterfacesIncGen MLIRCIROpInterfacesIncGen + MLIRCIRLoopOpInterfaceIncGen MLIRBuiltinLocationAttributesIncGen MLIRBuiltinTypeInterfacesIncGen MLIRFunctionInterfacesIncGen diff --git a/clang/lib/CIR/Interfaces/LoopOpInterface.cpp b/clang/lib/CIR/Interfaces/CIRLoopOpInterface.cpp similarity index 81% rename from clang/lib/CIR/Interfaces/LoopOpInterface.cpp rename to clang/lib/CIR/Interfaces/CIRLoopOpInterface.cpp index 7a481a82d857..f3e2d1e61274 100644 --- a/clang/lib/CIR/Interfaces/LoopOpInterface.cpp +++ b/clang/lib/CIR/Interfaces/CIRLoopOpInterface.cpp @@ -1,4 +1,4 @@ -//===- LoopOpInterface.cpp - Interface for CIR loop-like ops ---*- C++ -*-===// +//===- CIRLoopOpInterface.cpp - Interface for CIR loop-like ops *- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,10 +6,11 @@ // //===---------------------------------------------------------------------===// -#include "clang/CIR/Interfaces/LoopOpInterface.h" +#include "clang/CIR/Interfaces/CIRLoopOpInterface.h" #include "clang/CIR/Dialect/IR/CIRDialect.h" -#include "clang/CIR/Interfaces/LoopOpInterface.cpp.inc" +#include "clang/CIR/Interfaces/CIRLoopOpInterface.cpp.inc" +#include "llvm/Support/ErrorHandling.h" namespace mlir { namespace cir { @@ -28,14 +29,17 @@ void LoopOpInterface::getLoopOpSuccessorRegions( regions.emplace_back(RegionSuccessor(op->getResults())); regions.emplace_back(&op.getBody(), op.getBody().getArguments()); } - // Branching from body: go to step (for) or condition (while). + // Branching from body: go to step (for) or condition. else if (&op.getBody() == point.getRegionOrNull()) { + // FIXME(cir): Should we consider break/continue statements here? auto *afterBody = (op.maybeGetStep() ? op.maybeGetStep() : &op.getCond()); regions.emplace_back(afterBody, afterBody->getArguments()); } // Branching from step: go to condition. else if (op.maybeGetStep() == point.getRegionOrNull()) { regions.emplace_back(&op.getCond(), op.getCond().getArguments()); + } else { + llvm_unreachable("unexpected branch origin"); } } diff --git a/clang/lib/CIR/Interfaces/CMakeLists.txt b/clang/lib/CIR/Interfaces/CMakeLists.txt index 74d2c09ad61e..84322f4836e0 100644 --- a/clang/lib/CIR/Interfaces/CMakeLists.txt +++ b/clang/lib/CIR/Interfaces/CMakeLists.txt @@ -1,7 +1,7 @@ add_clang_library(MLIRCIRInterfaces ASTAttrInterfaces.cpp CIROpInterfaces.cpp - LoopOpInterface.cpp + CIRLoopOpInterface.cpp ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces @@ -9,6 +9,7 @@ add_clang_library(MLIRCIRInterfaces DEPENDS MLIRCIRASTAttrInterfacesIncGen MLIRCIROpInterfacesIncGen + MLIRCIRLoopOpInterfaceIncGen LINK_LIBS ${dialect_libs} diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt b/clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt index 14b879ee1c44..f613972126c8 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt +++ b/clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt @@ -14,6 +14,7 @@ add_clang_library(clangCIRLoweringDirectToLLVM MLIRCIROpsIncGen MLIRCIRASTAttrInterfacesIncGen MLIRCIROpInterfacesIncGen + MLIRCIRLoopOpInterfaceIncGen MLIRBuiltinLocationAttributesIncGen MLIRBuiltinTypeInterfacesIncGen MLIRFunctionInterfacesIncGen diff --git a/clang/lib/CIR/Lowering/ThroughMLIR/CMakeLists.txt b/clang/lib/CIR/Lowering/ThroughMLIR/CMakeLists.txt index d4a945ab7915..3ae144024ae7 100644 --- a/clang/lib/CIR/Lowering/ThroughMLIR/CMakeLists.txt +++ b/clang/lib/CIR/Lowering/ThroughMLIR/CMakeLists.txt @@ -14,6 +14,7 @@ add_clang_library(clangCIRLoweringThroughMLIR MLIRCIREnumsGen MLIRCIRASTAttrInterfacesIncGen MLIRCIROpInterfacesIncGen + MLIRCIRLoopOpInterfaceIncGen MLIRBuiltinLocationAttributesIncGen MLIRBuiltinTypeInterfacesIncGen MLIRFunctionInterfacesIncGen