From bc89e74ecf2ec00b2595f4bb7e0277fff230ebc9 Mon Sep 17 00:00:00 2001 From: xlauko Date: Tue, 24 Jun 2025 22:56:52 +0200 Subject: [PATCH] [CIR] Refactor type interfaces - Generalizes CIRFPTypeInterface files to CIRTypeInterfaces for future type interfaces additions. - Renames CIRFPTypeInterface to FPTypeInterface. - Fixes FPTypeInterface tablegen prefix. --- clang/include/clang/CIR/Dialect/IR/CIRAttrs.td | 6 +++--- clang/include/clang/CIR/Dialect/IR/CIRTypes.h | 2 +- clang/include/clang/CIR/Dialect/IR/CIRTypes.td | 4 ++-- ...{CIRFPTypeInterface.h => CIRTypeInterfaces.h} | 12 ++++++------ ...IRFPTypeInterface.td => CIRTypeInterfaces.td} | 14 +++++++++----- .../include/clang/CIR/Interfaces/CMakeLists.txt | 2 +- clang/lib/CIR/CodeGen/CIRGenBuilder.h | 2 +- clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp | 4 ++-- clang/lib/CIR/CodeGen/CIRGenExprConst.cpp | 4 ++-- clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 15 +++++++-------- clang/lib/CIR/Dialect/IR/CIRAttrs.cpp | 8 ++++---- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 16 ++++++++-------- clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 5 ++--- .../CIR/Dialect/Transforms/LoweringPrepare.cpp | 4 ++-- ...FPTypeInterface.cpp => CIRTypeInterfaces.cpp} | 6 +++--- clang/lib/CIR/Interfaces/CMakeLists.txt | 4 ++-- .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 16 ++++++++-------- clang/lib/CIR/Lowering/LoweringHelpers.cpp | 6 +++--- .../CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp | 10 +++++----- 19 files changed, 71 insertions(+), 69 deletions(-) rename clang/include/clang/CIR/Interfaces/{CIRFPTypeInterface.h => CIRTypeInterfaces.h} (57%) rename clang/include/clang/CIR/Interfaces/{CIRFPTypeInterface.td => CIRTypeInterfaces.td} (76%) rename clang/lib/CIR/Interfaces/{CIRFPTypeInterface.cpp => CIRTypeInterfaces.cpp} (64%) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index c7322771aa5e..e7451f9fde3f 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -444,17 +444,17 @@ def FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> { value of the specified floating-point type. Supporting only CIR FP types. }]; let parameters = (ins - AttributeSelfTypeParameter<"", "::cir::CIRFPTypeInterface">:$type, + AttributeSelfTypeParameter<"", "::cir::FPTypeInterface">:$type, APFloatParameter<"">:$value ); let builders = [ AttrBuilderWithInferredContext<(ins "mlir::Type":$type, "const llvm::APFloat &":$value), [{ - return $_get(type.getContext(), mlir::cast(type), value); + return $_get(type.getContext(), mlir::cast(type), value); }]>, AttrBuilder<(ins "mlir::Type":$type, "const llvm::APFloat &":$value), [{ - return $_get($_ctxt, mlir::cast(type), value); + return $_get($_ctxt, mlir::cast(type), value); }]>, ]; let extraClassDeclaration = [{ diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h index 0cd207f38f82..e7fb3c9ef83a 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h @@ -18,7 +18,7 @@ #include "mlir/Interfaces/DataLayoutInterfaces.h" #include "clang/CIR/Dialect/IR/CIROpsEnums.h" #include "clang/CIR/Interfaces/ASTAttrInterfaces.h" -#include "clang/CIR/Interfaces/CIRFPTypeInterface.h" +#include "clang/CIR/Interfaces/CIRTypeInterfaces.h" namespace cir { namespace detail { diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index 781ff9e56f65..cb3a0746909d 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -16,7 +16,7 @@ include "clang/CIR/Dialect/IR/CIRDialect.td" include "clang/CIR/Dialect/IR/CIRTypeConstraints.td" include "clang/CIR/Interfaces/ASTAttrInterfaces.td" -include "clang/CIR/Interfaces/CIRFPTypeInterface.td" +include "clang/CIR/Interfaces/CIRTypeInterfaces.td" include "mlir/Interfaces/DataLayoutInterfaces.td" include "mlir/IR/AttrTypeBase.td" include "mlir/IR/EnumAttr.td" @@ -82,7 +82,7 @@ def CIR_IntType : CIR_Type<"Int", "int", class CIR_FloatType : CIR_Type, - DeclareTypeInterfaceMethods + DeclareTypeInterfaceMethods ]>; def CIR_Single : CIR_FloatType<"Single", "float"> { diff --git a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h similarity index 57% rename from clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h rename to clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h index b2d75d40496f..d5d2f5a7fa65 100644 --- a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h +++ b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h @@ -1,4 +1,4 @@ -//===- CIRFPTypeInterface.h - Interface for CIR FP types -------*- 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,17 +6,17 @@ // //===---------------------------------------------------------------------===// // -// Defines the interface to generically handle CIR floating-point types. +// Defines cir type interfaces. // //===----------------------------------------------------------------------===// -#ifndef CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H -#define CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H +#ifndef CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_H +#define CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_H #include "mlir/IR/Types.h" #include "llvm/ADT/APFloat.h" /// Include the tablegen'd interface declarations. -#include "clang/CIR/Interfaces/CIRFPTypeInterface.h.inc" +#include "clang/CIR/Interfaces/CIRTypeInterfaces.h.inc" -#endif // CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H +#endif // CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_H diff --git a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.td similarity index 76% rename from clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td rename to clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.td index f1a9f9b36c9e..84147478f803 100644 --- a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td +++ b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.td @@ -1,17 +1,21 @@ -//===- CIRFPTypeInterface.td - CIR FP Interface Definitions -----*- C++ -*-===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +// +// Defines cir type interfaces. +// +//===----------------------------------------------------------------------===// -#ifndef MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE -#define MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE +#ifndef CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_TD +#define CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_TD include "mlir/IR/OpBase.td" -def CIRFPTypeInterface : TypeInterface<"CIRFPTypeInterface"> { +def CIR_FPTypeInterface : TypeInterface<"FPTypeInterface"> { let description = [{ Contains helper functions to query properties about a floating-point type. }]; @@ -49,4 +53,4 @@ def CIRFPTypeInterface : TypeInterface<"CIRFPTypeInterface"> { ]; } -#endif // MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE +#endif // CLANG_CIR_INTERFACES_CIRTYPEINTERFACES_TD diff --git a/clang/include/clang/CIR/Interfaces/CMakeLists.txt b/clang/include/clang/CIR/Interfaces/CMakeLists.txt index 86fffa3f9307..2589e95e5d69 100644 --- a/clang/include/clang/CIR/Interfaces/CMakeLists.txt +++ b/clang/include/clang/CIR/Interfaces/CMakeLists.txt @@ -31,4 +31,4 @@ endfunction() add_clang_mlir_attr_interface(ASTAttrInterfaces) add_clang_mlir_op_interface(CIROpInterfaces) add_clang_mlir_op_interface(CIRLoopOpInterface) -add_clang_mlir_type_interface(CIRFPTypeInterface) +add_clang_mlir_type_interface(CIRTypeInterfaces) diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 046030805ee5..255314a89465 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -529,7 +529,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { bool isSized(mlir::Type ty) { if (mlir::isa(ty)) return true; if (mlir::isa(ty)) { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp index 1ed9b100411d..d07c64addbe0 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp @@ -2,7 +2,7 @@ #include "CIRGenCstEmitter.h" #include "CIRGenFunction.h" #include "clang/Basic/LangOptions.h" -#include "clang/CIR/Interfaces/CIRFPTypeInterface.h" +#include "clang/CIR/Interfaces/CIRTypeInterfaces.h" #include "clang/CIR/MissingFeatures.h" #include "mlir/IR/Location.h" @@ -844,7 +844,7 @@ ComplexExprEmitter::VisitImaginaryLiteral(const ImaginaryLiteral *IL) { auto ImagValue = cast(IL->getSubExpr())->getValue(); RealValueAttr = cir::IntAttr::get(ElementTy, 0); ImagValueAttr = cir::IntAttr::get(ElementTy, ImagValue); - } else if (mlir::isa(ElementTy)) { + } else if (mlir::isa(ElementTy)) { auto ImagValue = cast(IL->getSubExpr())->getValue(); RealValueAttr = cir::FPAttr::get( ElementTy, llvm::APFloat::getZero(ImagValue.getSemantics())); diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp index 426f6eb0411d..dc173bc41dd2 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp @@ -1916,7 +1916,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &Value, assert(0 && "not implemented"); else { mlir::Type ty = CGM.convertType(DestType); - assert(mlir::isa(ty) && + assert(mlir::isa(ty) && "expected floating-point type"); return CGM.getBuilder().getAttr(ty, Init); } @@ -2022,7 +2022,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &Value, builder.getAttr(complexElemTy, imag)); } - assert(isa(complexElemTy) && + assert(isa(complexElemTy) && "expected floating-point type"); llvm::APFloat real = Value.getComplexFloatReal(); llvm::APFloat imag = Value.getComplexFloatImag(); diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 3a6cdd712d7d..5938750e4921 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -183,8 +183,7 @@ class ScalarExprEmitter : public StmtVisitor { } mlir::Value VisitFloatingLiteral(const FloatingLiteral *E) { mlir::Type Ty = CGF.convertType(E->getType()); - assert(mlir::isa(Ty) && - "expect floating-point type"); + assert(mlir::isa(Ty) && "expect floating-point type"); return Builder.create( CGF.getLoc(E->getExprLoc()), Builder.getAttr(Ty, E->getValue())); @@ -1047,7 +1046,7 @@ class ScalarExprEmitter : public StmtVisitor { if (SrcType->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) { // Cast to FP using the intrinsic if the half type itself isn't supported. - if (mlir::isa(DstTy)) { + if (mlir::isa(DstTy)) { if (CGF.getContext().getTargetInfo().useFP16ConversionIntrinsics()) llvm_unreachable("cast via llvm.convert.from.fp16 is NYI"); } else { @@ -1118,7 +1117,7 @@ class ScalarExprEmitter : public StmtVisitor { if (DstType->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) { // Make sure we cast in a single step if from another FP type. - if (mlir::isa(SrcTy)) { + if (mlir::isa(SrcTy)) { // Use the intrinsic if the half type itself isn't supported // (as opposed to operations on half, available with NativeHalfType). if (CGF.getContext().getTargetInfo().useFP16ConversionIntrinsics()) @@ -2118,7 +2117,7 @@ mlir::Value ScalarExprEmitter::emitScalarCast(mlir::Value Src, QualType SrcType, llvm_unreachable("NYI: signed bool"); if (CGF.getBuilder().isInt(DstTy)) { CastKind = cir::CastKind::bool_to_int; - } else if (mlir::isa(DstTy)) { + } else if (mlir::isa(DstTy)) { CastKind = cir::CastKind::bool_to_float; } else { llvm_unreachable("Internal error: Cast to unexpected type"); @@ -2126,12 +2125,12 @@ mlir::Value ScalarExprEmitter::emitScalarCast(mlir::Value Src, QualType SrcType, } else if (CGF.getBuilder().isInt(SrcTy)) { if (CGF.getBuilder().isInt(DstTy)) { CastKind = cir::CastKind::integral; - } else if (mlir::isa(DstTy)) { + } else if (mlir::isa(DstTy)) { CastKind = cir::CastKind::int_to_float; } else { llvm_unreachable("Internal error: Cast to unexpected type"); } - } else if (mlir::isa(SrcTy)) { + } else if (mlir::isa(SrcTy)) { if (CGF.getBuilder().isInt(DstTy)) { // If we can't recognize overflow as undefined behavior, assume that // overflow saturates. This protects against normal optimizations if we @@ -2141,7 +2140,7 @@ mlir::Value ScalarExprEmitter::emitScalarCast(mlir::Value Src, QualType SrcType, if (Builder.getIsFPConstrained()) llvm_unreachable("NYI"); CastKind = cir::CastKind::float_to_int; - } else if (mlir::isa(DstTy)) { + } else if (mlir::isa(DstTy)) { // TODO: split this to createFPExt/createFPTrunc return Builder.createFloatingCast(Src, FullDstTy); } else { diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp index a06348e2ab18..b588ba1b96f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp @@ -43,7 +43,7 @@ static void printFloatLiteral(mlir::AsmPrinter &p, llvm::APFloat value, static mlir::ParseResult parseFloatLiteral(mlir::AsmParser &parser, mlir::FailureOr &value, - cir::CIRFPTypeInterface fpType); + cir::FPTypeInterface fpType); static mlir::ParseResult parseConstPtr(mlir::AsmParser &parser, mlir::IntegerAttr &value); @@ -276,7 +276,7 @@ static void printFloatLiteral(AsmPrinter &p, APFloat value, Type ty) { static ParseResult parseFloatLiteral(AsmParser &parser, FailureOr &value, - CIRFPTypeInterface fpType) { + cir::FPTypeInterface fpType) { APFloat parsedValue(0.0); if (parser.parseFloat(fpType.getFloatSemantics(), parsedValue)) @@ -289,11 +289,11 @@ static ParseResult parseFloatLiteral(AsmParser &parser, FPAttr FPAttr::getZero(Type type) { return get(type, APFloat::getZero( - mlir::cast(type).getFloatSemantics())); + mlir::cast(type).getFloatSemantics())); } LogicalResult FPAttr::verify(function_ref emitError, - CIRFPTypeInterface fpType, APFloat value) { + cir::FPTypeInterface fpType, APFloat value) { if (APFloat::SemanticsToEnum(fpType.getFloatSemantics()) != APFloat::SemanticsToEnum(value.getSemantics())) return emitError() << "floating-point semantics mismatch"; diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 919acbe00224..9f48f202cfbc 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -579,13 +579,13 @@ LogicalResult cir::CastOp::verify() { return success(); } case cir::CastKind::floating: { - if (!mlir::isa(srcType) || - !mlir::isa(resType)) + if (!mlir::isa(srcType) || + !mlir::isa(resType)) return emitOpError() << "requires !cir.float type for source and result"; return success(); } case cir::CastKind::float_to_int: { - if (!mlir::isa(srcType)) + if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; if (!mlir::dyn_cast(resType)) return emitOpError() << "requires !cir.int type for result"; @@ -606,7 +606,7 @@ LogicalResult cir::CastOp::verify() { return success(); } case cir::CastKind::float_to_bool: { - if (!mlir::isa(srcType)) + if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.bool type for result"; @@ -622,14 +622,14 @@ LogicalResult cir::CastOp::verify() { case cir::CastKind::int_to_float: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; - if (!mlir::isa(resType)) + if (!mlir::isa(resType)) return emitOpError() << "requires !cir.float type for result"; return success(); } case cir::CastKind::bool_to_float: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.bool type for source"; - if (!mlir::isa(resType)) + if (!mlir::isa(resType)) return emitOpError() << "requires !cir.float type for result"; return success(); } @@ -643,7 +643,7 @@ LogicalResult cir::CastOp::verify() { return success(); } case cir::CastKind::float_to_complex: { - if (!mlir::isa(srcType)) + if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; auto resComplexTy = mlir::dyn_cast(resType); if (!resComplexTy) @@ -666,7 +666,7 @@ LogicalResult cir::CastOp::verify() { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy) return emitOpError() << "requires !cir.complex type for source"; - if (!mlir::isa(resType)) + if (!mlir::isa(resType)) return emitOpError() << "requires !cir.float type for result"; if (srcComplexTy.getElementType() != resType) return emitOpError() << "requires source element type match result type"; diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp index e34232af2d83..cd9ab5f3ccc5 100644 --- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp @@ -26,7 +26,7 @@ #include "mlir/Support/LogicalResult.h" #include "clang/CIR/Interfaces/ASTAttrInterfaces.h" -#include "clang/CIR/Interfaces/CIRFPTypeInterface.h" +#include "clang/CIR/Interfaces/CIRTypeInterfaces.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" @@ -732,8 +732,7 @@ uint64_t FP128Type::getABIAlignment(const mlir::DataLayout &dataLayout, } const llvm::fltSemantics &LongDoubleType::getFloatSemantics() const { - return mlir::cast(getUnderlying()) - .getFloatSemantics(); + return mlir::cast(getUnderlying()).getFloatSemantics(); } llvm::TypeSize diff --git a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp index b9b1bb774401..253f098278de 100644 --- a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp +++ b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp @@ -589,7 +589,7 @@ static mlir::Value buildComplexBinOpLibCall( llvm::StringRef (*libFuncNameGetter)(llvm::APFloat::Semantics), mlir::Location loc, cir::ComplexType ty, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag) { - auto elementTy = mlir::cast(ty.getElementType()); + auto elementTy = mlir::cast(ty.getElementType()); auto libFuncName = libFuncNameGetter( llvm::APFloat::SemanticsToEnum(elementTy.getFloatSemantics())); @@ -807,7 +807,7 @@ static mlir::Value lowerComplexDiv(LoweringPreparePass &pass, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag) { auto ty = op.getType(); - if (mlir::isa(ty.getElementType())) { + if (mlir::isa(ty.getElementType())) { auto range = op.getRange(); if (range == cir::ComplexRangeKind::Improved || (range == cir::ComplexRangeKind::Promoted && !op.getPromoted())) diff --git a/clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp b/clang/lib/CIR/Interfaces/CIRTypeInterfaces.cpp similarity index 64% rename from clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp rename to clang/lib/CIR/Interfaces/CIRTypeInterfaces.cpp index 5bf692628396..f9500bbe1fdb 100644 --- a/clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp +++ b/clang/lib/CIR/Interfaces/CIRTypeInterfaces.cpp @@ -1,4 +1,4 @@ -//====- CIRFPTypeInterface.cpp - Interface for floating-point types -------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// -#include "clang/CIR/Interfaces/CIRFPTypeInterface.h" +#include "clang/CIR/Interfaces/CIRTypeInterfaces.h" using namespace cir; /// Include the generated interfaces. -#include "clang/CIR/Interfaces/CIRFPTypeInterface.cpp.inc" +#include "clang/CIR/Interfaces/CIRTypeInterfaces.cpp.inc" diff --git a/clang/lib/CIR/Interfaces/CMakeLists.txt b/clang/lib/CIR/Interfaces/CMakeLists.txt index dee0a1408250..33eb169708a4 100644 --- a/clang/lib/CIR/Interfaces/CMakeLists.txt +++ b/clang/lib/CIR/Interfaces/CMakeLists.txt @@ -2,7 +2,7 @@ add_clang_library(MLIRCIRInterfaces ASTAttrInterfaces.cpp CIROpInterfaces.cpp CIRLoopOpInterface.cpp - CIRFPTypeInterface.cpp + CIRTypeInterfaces.cpp ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces @@ -10,7 +10,7 @@ add_clang_library(MLIRCIRInterfaces DEPENDS MLIRCIRASTAttrInterfacesIncGen MLIRCIREnumsGen - MLIRCIRFPTypeInterfaceIncGen + MLIRCIRTypeInterfacesIncGen MLIRCIRLoopOpInterfaceIncGen MLIRCIROpInterfacesIncGen diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index da5c7d1782cf..0a42a90aa1d6 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -1226,12 +1226,12 @@ mlir::LogicalResult CIRToLLVMCastOpLowering::matchAndRewrite( auto srcTy = elementTypeIfVector(castOp.getSrc().getType()); auto dstTy = elementTypeIfVector(castOp.getType()); - if (!mlir::isa(dstTy) || - !mlir::isa(srcTy)) + if (!mlir::isa(dstTy) || + !mlir::isa(srcTy)) return castOp.emitError() << "NYI cast from " << srcTy << " to " << dstTy; auto getFloatWidth = [](mlir::Type ty) -> unsigned { - return mlir::cast(ty).getWidth(); + return mlir::cast(ty).getWidth(); }; if (getFloatWidth(srcTy) > getFloatWidth(dstTy)) @@ -1797,7 +1797,7 @@ mlir::LogicalResult CIRToLLVMConstantOpLowering::matchAndRewrite( attr = rewriter.getIntegerAttr( typeConverter->convertType(op.getType()), mlir::cast(op.getValue()).getValue()); - } else if (mlir::isa(op.getType())) { + } else if (mlir::isa(op.getType())) { attr = rewriter.getFloatAttr( typeConverter->convertType(op.getType()), mlir::cast(op.getValue()).getValue()); @@ -1955,7 +1955,7 @@ mlir::LogicalResult CIRToLLVMVecCmpOpLowering::matchAndRewrite( op.getLoc(), convertCmpKindToICmpPredicate(op.getKind(), intType.isSigned()), adaptor.getLhs(), adaptor.getRhs()); - } else if (mlir::isa(elementType)) { + } else if (mlir::isa(elementType)) { bitResult = rewriter.create( op.getLoc(), convertCmpKindToFCmpPredicate(op.getKind()), adaptor.getLhs(), adaptor.getRhs()); @@ -2695,7 +2695,7 @@ mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite( } // Floating point unary operations: + - ++ -- - if (mlir::isa(elementType)) { + if (mlir::isa(elementType)) { switch (op.getKind()) { case cir::UnaryOpKind::Inc: { assert(!IsVector && "++ not allowed on vector types"); @@ -2787,7 +2787,7 @@ mlir::LogicalResult CIRToLLVMBinOpLowering::matchAndRewrite( "inconsistent operands' types not supported yet"); mlir::Type type = op.getRhs().getType(); - assert((mlir::isa(type)) && "operand type not supported yet"); @@ -3071,7 +3071,7 @@ mlir::LogicalResult CIRToLLVMCmpOpLowering::matchAndRewrite( /* isSigned=*/false); rewriter.replaceOpWithNewOp( cmpOp, kind, adaptor.getLhs(), adaptor.getRhs()); - } else if (mlir::isa(type)) { + } else if (mlir::isa(type)) { auto kind = convertCmpKindToFCmpPredicate(cmpOp.getKind()); rewriter.replaceOpWithNewOp( cmpOp, kind, adaptor.getLhs(), adaptor.getRhs()); diff --git a/clang/lib/CIR/Lowering/LoweringHelpers.cpp b/clang/lib/CIR/Lowering/LoweringHelpers.cpp index 0dd209fdb6b9..e4e2f3ddd2ff 100644 --- a/clang/lib/CIR/Lowering/LoweringHelpers.cpp +++ b/clang/lib/CIR/Lowering/LoweringHelpers.cpp @@ -225,7 +225,7 @@ lowerConstArrayAttr(cir::ConstArrayAttr constArr, if (mlir::isa(type)) return convertToDenseElementsAttr( constArr, dims, type, converter->convertType(type)); - if (mlir::isa(type)) + if (mlir::isa(type)) return convertToDenseElementsAttr( constArr, dims, type, converter->convertType(type)); @@ -246,7 +246,7 @@ lowerConstComplexAttr(cir::ComplexAttr constComplex, if (mlir::isa(type)) return convertToDenseElementsAttr( constComplex, dims, type, converter->convertType(type)); - if (mlir::isa(type)) + if (mlir::isa(type)) return convertToDenseElementsAttr( constComplex, dims, type, converter->convertType(type)); @@ -276,7 +276,7 @@ lowerConstVectorAttr(cir::ConstVectorAttr constArr, if (mlir::isa(type)) return convertToDenseElementsAttr( constArr, dims, type, converter->convertType(type)); - if (mlir::isa(type)) + if (mlir::isa(type)) return convertToDenseElementsAttr( constArr, dims, type, converter->convertType(type)); diff --git a/clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp b/clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp index 5800773e715b..1d8ccc652f39 100644 --- a/clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp +++ b/clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp @@ -881,7 +881,7 @@ class CIRCmpOpLowering : public mlir::OpConversionPattern { auto kind = convertCmpKindToCmpIPredicate(op.getKind(), ty.isSigned()); rewriter.replaceOpWithNewOp( op, kind, adaptor.getLhs(), adaptor.getRhs()); - } else if (auto ty = mlir::dyn_cast(type)) { + } else if (auto ty = mlir::dyn_cast(type)) { auto kind = convertCmpKindToCmpFPredicate(op.getKind()); rewriter.replaceOpWithNewOp( op, kind, adaptor.getLhs(), adaptor.getRhs()); @@ -1210,7 +1210,7 @@ class CIRVectorCmpOpLowering : public mlir::OpConversionPattern { op.getLoc(), convertCmpKindToCmpIPredicate(op.getKind(), intType.isSigned()), adaptor.getLhs(), adaptor.getRhs()); - } else if (mlir::isa(elementType)) { + } else if (mlir::isa(elementType)) { bitResult = rewriter.create( op.getLoc(), convertCmpKindToCmpFPredicate(op.getKind()), adaptor.getLhs(), adaptor.getRhs()); @@ -1269,12 +1269,12 @@ class CIRCastOpLowering : public mlir::OpConversionPattern { auto srcTy = op.getSrc().getType(); auto dstTy = op.getType(); - if (!mlir::isa(dstTy) || - !mlir::isa(srcTy)) + if (!mlir::isa(dstTy) || + !mlir::isa(srcTy)) return op.emitError() << "NYI cast from " << srcTy << " to " << dstTy; auto getFloatWidth = [](mlir::Type ty) -> unsigned { - return mlir::cast(ty).getWidth(); + return mlir::cast(ty).getWidth(); }; if (getFloatWidth(srcTy) > getFloatWidth(dstTy))