[clang] [CIR] Refactor type interfaces (PR #146044)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 27 02:27:19 PDT 2025
https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/146044
- Generalizes CIRFPTypeInterface files to CIRTypeInterfaces for future type interfaces additions.
- Renames CIRFPTypeInterface to FPTypeInterface.
- Fixes FPTypeInterface tablegen prefix.
This mirrors incubator changes from https://github.com/llvm/clangir/pull/1713
>From 6d5e70e7fcc4f56f9f1c8a2ac519339e02720f21 Mon Sep 17 00:00:00 2001
From: xlauko <xlauko at mail.muni.cz>
Date: Fri, 27 Jun 2025 10:01:26 +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.
This mirrors incubator changes from https://github.com/llvm/clangir/pull/1713
---
clang/include/clang/CIR/Dialect/IR/CIRAttrs.td | 7 +++----
clang/include/clang/CIR/Dialect/IR/CIRTypes.h | 2 +-
clang/include/clang/CIR/Dialect/IR/CIRTypes.td | 4 ++--
...{CIRFPTypeInterface.h => CIRTypeInterfaces.h} | 10 +++++-----
...IRFPTypeInterface.td => CIRTypeInterfaces.td} | 10 +++++-----
.../include/clang/CIR/Interfaces/CMakeLists.txt | 2 +-
clang/lib/CIR/CodeGen/CIRGenBuilder.cpp | 3 +--
clang/lib/CIR/CodeGen/CIRGenBuilder.h | 5 ++---
clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp | 2 +-
clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp | 4 ++--
clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 12 ++++++------
clang/lib/CIR/Dialect/IR/CIRAttrs.cpp | 8 ++++----
clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 12 ++++++------
clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 3 +--
...FPTypeInterface.cpp => CIRTypeInterfaces.cpp} | 6 +++---
clang/lib/CIR/Interfaces/CMakeLists.txt | 4 ++--
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 16 ++++++++--------
clang/lib/CIR/Lowering/LoweringHelpers.cpp | 2 +-
18 files changed, 54 insertions(+), 58 deletions(-)
rename clang/include/clang/CIR/Interfaces/{CIRFPTypeInterface.h => CIRTypeInterfaces.h} (62%)
rename clang/include/clang/CIR/Interfaces/{CIRFPTypeInterface.td => CIRTypeInterfaces.td} (81%)
rename clang/lib/CIR/Interfaces/{CIRFPTypeInterface.cpp => CIRTypeInterfaces.cpp} (73%)
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 03e970db2847d..9a6560519eec4 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -160,18 +160,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<CIRFPTypeInterface>(type),
- value);
+ return $_get(type.getContext(), mlir::cast<FPTypeInterface>(type), value);
}]>,
AttrBuilder<(ins "mlir::Type":$type,
"const llvm::APFloat &":$value), [{
- return $_get($_ctxt, mlir::cast<CIRFPTypeInterface>(type), value);
+ return $_get($_ctxt, mlir::cast<FPTypeInterface>(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 49933be724a04..620c72ef9023e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
@@ -16,7 +16,7 @@
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/Types.h"
#include "mlir/Interfaces/DataLayoutInterfaces.h"
-#include "clang/CIR/Interfaces/CIRFPTypeInterface.h"
+#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
namespace cir {
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
index 41d7d725a09e0..75c42a08c185f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
@@ -15,7 +15,7 @@
include "clang/CIR/Dialect/IR/CIRDialect.td"
include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
-include "clang/CIR/Interfaces/CIRFPTypeInterface.td"
+include "clang/CIR/Interfaces/CIRTypeInterfaces.td"
include "mlir/Interfaces/DataLayoutInterfaces.td"
include "mlir/IR/AttrTypeBase.td"
@@ -82,7 +82,7 @@ def CIR_IntType : CIR_Type<"Int", "int",
class CIR_FloatType<string name, string mnemonic> : CIR_Type<name, mnemonic, [
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
- DeclareTypeInterfaceMethods<CIRFPTypeInterface>
+ DeclareTypeInterfaceMethods<CIR_FPTypeInterface>
]>;
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 62%
rename from clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h
rename to clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
index 40b85ef6cfb62..d5d2f5a7fa657 100644
--- a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h
+++ b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
@@ -6,17 +6,17 @@
//
//===---------------------------------------------------------------------===//
//
-// Defines the interface to generically handle CIR floating-point types.
+// Defines cir type interfaces.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_H
-#define LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_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 // LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_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 81%
rename from clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td
rename to clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.td
index 973851b61444f..84147478f8030 100644
--- a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td
+++ b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.td
@@ -6,16 +6,16 @@
//
//===----------------------------------------------------------------------===//
//
-// Defines the interface to generically handle CIR floating-point types.
+// Defines cir type interfaces.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_TD
-#define LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_TD
+#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.
}];
@@ -53,4 +53,4 @@ def CIRFPTypeInterface : TypeInterface<"CIRFPTypeInterface"> {
];
}
-#endif // LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_TD
+#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 3c155193235d7..bc8d94ff9dc56 100644
--- a/clang/include/clang/CIR/Interfaces/CMakeLists.txt
+++ b/clang/include/clang/CIR/Interfaces/CMakeLists.txt
@@ -21,4 +21,4 @@ endfunction()
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.cpp b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
index 9cec17bcb2fd0..b94963c71f9c1 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
@@ -62,8 +62,7 @@ cir::ConstantOp CIRGenBuilderTy::getConstInt(mlir::Location loc, mlir::Type t,
cir::ConstantOp
clang::CIRGen::CIRGenBuilderTy::getConstFP(mlir::Location loc, mlir::Type t,
llvm::APFloat fpVal) {
- assert(mlir::isa<cir::CIRFPTypeInterface>(t) &&
- "expected floating point type");
+ assert(mlir::isa<cir::FPTypeInterface>(t) && "expected floating point type");
return create<cir::ConstantOp>(loc, getAttr<cir::FPAttr>(t, fpVal));
}
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
index ac62ea7c6aa16..e316c39b98919 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
@@ -11,7 +11,7 @@
#include "Address.h"
#include "CIRGenTypeCache.h"
-#include "clang/CIR/Interfaces/CIRFPTypeInterface.h"
+#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
#include "clang/CIR/MissingFeatures.h"
#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
@@ -141,8 +141,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
bool isSized(mlir::Type ty) {
if (mlir::isa<cir::PointerType, cir::ArrayType, cir::BoolType, cir::IntType,
- cir::CIRFPTypeInterface, cir::ComplexType, cir::RecordType>(
- ty))
+ cir::FPTypeInterface, cir::ComplexType, cir::RecordType>(ty))
return true;
if (const auto vt = mlir::dyn_cast<cir::VectorType>(ty))
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp
index 9a883cba46ce8..43f2e47eac152 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp
@@ -195,7 +195,7 @@ ComplexExprEmitter::VisitImaginaryLiteral(const ImaginaryLiteral *il) {
realValueAttr = cir::IntAttr::get(elementTy, 0);
imagValueAttr = cir::IntAttr::get(elementTy, imagValue);
} else {
- assert(mlir::isa<cir::CIRFPTypeInterface>(elementTy) &&
+ assert(mlir::isa<cir::FPTypeInterface>(elementTy) &&
"Expected complex element type to be floating-point");
llvm::APFloat imagValue =
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index 8b817f3f3d8d2..e25819cdb11bf 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -696,7 +696,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &value,
}
mlir::Type ty = cgm.convertType(destType);
- assert(mlir::isa<cir::CIRFPTypeInterface>(ty) &&
+ assert(mlir::isa<cir::FPTypeInterface>(ty) &&
"expected floating-point type");
return cgm.getBuilder().getAttr<cir::FPAttr>(ty, init);
}
@@ -793,7 +793,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &value,
builder.getAttr<cir::IntAttr>(complexElemTy, imag));
}
- assert(isa<cir::CIRFPTypeInterface>(complexElemTy) &&
+ assert(isa<cir::FPTypeInterface>(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 4bcbc6d7ce798..b6270ea36fe05 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -155,7 +155,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
mlir::Value VisitFloatingLiteral(const FloatingLiteral *e) {
mlir::Type type = cgf.convertType(e->getType());
- assert(mlir::isa<cir::CIRFPTypeInterface>(type) &&
+ assert(mlir::isa<cir::FPTypeInterface>(type) &&
"expect floating-point type");
return builder.create<cir::ConstantOp>(
cgf.getLoc(e->getExprLoc()),
@@ -331,18 +331,18 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
cgf.getCIRGenModule().errorNYI("signed bool");
if (cgf.getBuilder().isInt(dstTy))
castKind = cir::CastKind::bool_to_int;
- else if (mlir::isa<cir::CIRFPTypeInterface>(dstTy))
+ else if (mlir::isa<cir::FPTypeInterface>(dstTy))
castKind = cir::CastKind::bool_to_float;
else
llvm_unreachable("Internal error: Cast to unexpected type");
} else if (cgf.getBuilder().isInt(srcTy)) {
if (cgf.getBuilder().isInt(dstTy))
castKind = cir::CastKind::integral;
- else if (mlir::isa<cir::CIRFPTypeInterface>(dstTy))
+ else if (mlir::isa<cir::FPTypeInterface>(dstTy))
castKind = cir::CastKind::int_to_float;
else
llvm_unreachable("Internal error: Cast to unexpected type");
- } else if (mlir::isa<cir::CIRFPTypeInterface>(srcTy)) {
+ } else if (mlir::isa<cir::FPTypeInterface>(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
@@ -351,7 +351,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
cgf.getCIRGenModule().errorNYI("strict float cast overflow");
assert(!cir::MissingFeatures::fpConstraints());
castKind = cir::CastKind::float_to_int;
- } else if (mlir::isa<cir::CIRFPTypeInterface>(dstTy)) {
+ } else if (mlir::isa<cir::FPTypeInterface>(dstTy)) {
// TODO: split this to createFPExt/createFPTrunc
return builder.createFloatingCast(src, fullDstTy);
} else {
@@ -654,7 +654,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
if (srcType->isHalfType() &&
!cgf.getContext().getLangOpts().NativeHalfType) {
// Cast to FP using the intrinsic if the half type itself isn't supported.
- if (mlir::isa<cir::CIRFPTypeInterface>(mlirDstType)) {
+ if (mlir::isa<cir::FPTypeInterface>(mlirDstType)) {
if (cgf.getContext().getTargetInfo().useFP16ConversionIntrinsics())
cgf.getCIRGenModule().errorNYI(loc,
"cast via llvm.convert.from.fp16");
diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
index b52e9c3e49199..29a9a815c31a1 100644
--- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
@@ -20,7 +20,7 @@ static void printFloatLiteral(mlir::AsmPrinter &p, llvm::APFloat value,
static mlir::ParseResult
parseFloatLiteral(mlir::AsmParser &parser,
mlir::FailureOr<llvm::APFloat> &value,
- cir::CIRFPTypeInterface fpType);
+ cir::FPTypeInterface fpType);
static mlir::ParseResult parseConstPtr(mlir::AsmParser &parser,
mlir::IntegerAttr &value);
@@ -158,7 +158,7 @@ static void printFloatLiteral(AsmPrinter &p, APFloat value, Type ty) {
static ParseResult parseFloatLiteral(AsmParser &parser,
FailureOr<APFloat> &value,
- CIRFPTypeInterface fpType) {
+ cir::FPTypeInterface fpType) {
APFloat parsedValue(0.0);
if (parser.parseFloat(fpType.getFloatSemantics(), parsedValue))
@@ -171,11 +171,11 @@ static ParseResult parseFloatLiteral(AsmParser &parser,
FPAttr FPAttr::getZero(Type type) {
return get(type,
APFloat::getZero(
- mlir::cast<CIRFPTypeInterface>(type).getFloatSemantics()));
+ mlir::cast<cir::FPTypeInterface>(type).getFloatSemantics()));
}
LogicalResult FPAttr::verify(function_ref<InFlightDiagnostic()> 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 17157561357f9..52569659d9c73 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -421,13 +421,13 @@ LogicalResult cir::CastOp::verify() {
return success();
}
case cir::CastKind::floating: {
- if (!mlir::isa<cir::CIRFPTypeInterface>(srcType) ||
- !mlir::isa<cir::CIRFPTypeInterface>(resType))
+ if (!mlir::isa<cir::FPTypeInterface>(srcType) ||
+ !mlir::isa<cir::FPTypeInterface>(resType))
return emitOpError() << "requires !cir.float type for source and result";
return success();
}
case cir::CastKind::float_to_int: {
- if (!mlir::isa<cir::CIRFPTypeInterface>(srcType))
+ if (!mlir::isa<cir::FPTypeInterface>(srcType))
return emitOpError() << "requires !cir.float type for source";
if (!mlir::dyn_cast<cir::IntType>(resType))
return emitOpError() << "requires !cir.int type for result";
@@ -448,7 +448,7 @@ LogicalResult cir::CastOp::verify() {
return success();
}
case cir::CastKind::float_to_bool: {
- if (!mlir::isa<cir::CIRFPTypeInterface>(srcType))
+ if (!mlir::isa<cir::FPTypeInterface>(srcType))
return emitOpError() << "requires !cir.float type for source";
if (!mlir::isa<cir::BoolType>(resType))
return emitOpError() << "requires !cir.bool type for result";
@@ -464,14 +464,14 @@ LogicalResult cir::CastOp::verify() {
case cir::CastKind::int_to_float: {
if (!mlir::isa<cir::IntType>(srcType))
return emitOpError() << "requires !cir.int type for source";
- if (!mlir::isa<cir::CIRFPTypeInterface>(resType))
+ if (!mlir::isa<cir::FPTypeInterface>(resType))
return emitOpError() << "requires !cir.float type for result";
return success();
}
case cir::CastKind::bool_to_float: {
if (!mlir::isa<cir::BoolType>(srcType))
return emitOpError() << "requires !cir.bool type for source";
- if (!mlir::isa<cir::CIRFPTypeInterface>(resType))
+ if (!mlir::isa<cir::FPTypeInterface>(resType))
return emitOpError() << "requires !cir.float type for result";
return success();
}
diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
index 09926a93eb6f3..1db5a9728fdb9 100644
--- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
@@ -539,8 +539,7 @@ uint64_t FP128Type::getABIAlignment(const mlir::DataLayout &dataLayout,
}
const llvm::fltSemantics &LongDoubleType::getFloatSemantics() const {
- return mlir::cast<cir::CIRFPTypeInterface>(getUnderlying())
- .getFloatSemantics();
+ return mlir::cast<cir::FPTypeInterface>(getUnderlying()).getFloatSemantics();
}
llvm::TypeSize
diff --git a/clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp b/clang/lib/CIR/Interfaces/CIRTypeInterfaces.cpp
similarity index 73%
rename from clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp
rename to clang/lib/CIR/Interfaces/CIRTypeInterfaces.cpp
index 41817e90b5232..8c0daa03b2ff1 100644
--- a/clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp
+++ b/clang/lib/CIR/Interfaces/CIRTypeInterfaces.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
//
-// Defines the interface to generically handle CIR floating-point types.
+// Defines cir type interfaces.
//
//===----------------------------------------------------------------------===//
-#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 04a8972fba9ae..13e4c2040f1c7 100644
--- a/clang/lib/CIR/Interfaces/CMakeLists.txt
+++ b/clang/lib/CIR/Interfaces/CMakeLists.txt
@@ -1,14 +1,14 @@
add_clang_library(MLIRCIRInterfaces
CIROpInterfaces.cpp
CIRLoopOpInterface.cpp
- CIRFPTypeInterface.cpp
+ CIRTypeInterfaces.cpp
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces
DEPENDS
MLIRCIREnumsGen
- MLIRCIRFPTypeInterfaceIncGen
+ MLIRCIRTypeInterfacesIncGen
MLIRCIRLoopOpInterfaceIncGen
MLIRCIROpInterfacesIncGen
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index d510f1c756936..1034b8780c03c 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -529,12 +529,12 @@ mlir::LogicalResult CIRToLLVMCastOpLowering::matchAndRewrite(
mlir::Type srcTy = elementTypeIfVector(castOp.getSrc().getType());
mlir::Type dstTy = elementTypeIfVector(castOp.getType());
- if (!mlir::isa<cir::CIRFPTypeInterface>(dstTy) ||
- !mlir::isa<cir::CIRFPTypeInterface>(srcTy))
+ if (!mlir::isa<cir::FPTypeInterface>(dstTy) ||
+ !mlir::isa<cir::FPTypeInterface>(srcTy))
return castOp.emitError() << "NYI cast from " << srcTy << " to " << dstTy;
auto getFloatWidth = [](mlir::Type ty) -> unsigned {
- return mlir::cast<cir::CIRFPTypeInterface>(ty).getWidth();
+ return mlir::cast<cir::FPTypeInterface>(ty).getWidth();
};
if (getFloatWidth(srcTy) > getFloatWidth(dstTy))
@@ -928,7 +928,7 @@ mlir::LogicalResult CIRToLLVMConstantOpLowering::matchAndRewrite(
attr = rewriter.getIntegerAttr(
typeConverter->convertType(op.getType()),
mlir::cast<cir::IntAttr>(op.getValue()).getValue());
- } else if (mlir::isa<cir::CIRFPTypeInterface>(op.getType())) {
+ } else if (mlir::isa<cir::FPTypeInterface>(op.getType())) {
attr = rewriter.getFloatAttr(
typeConverter->convertType(op.getType()),
mlir::cast<cir::FPAttr>(op.getValue()).getValue());
@@ -1349,7 +1349,7 @@ mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
}
// Floating point unary operations: + - ++ --
- if (mlir::isa<cir::CIRFPTypeInterface>(elementType)) {
+ if (mlir::isa<cir::FPTypeInterface>(elementType)) {
switch (op.getKind()) {
case cir::UnaryOpKind::Inc: {
assert(!isVector && "++ not allowed on vector types");
@@ -1438,7 +1438,7 @@ mlir::LogicalResult CIRToLLVMBinOpLowering::matchAndRewrite(
return op.emitError() << "inconsistent operands' types not supported yet";
mlir::Type type = op.getRhs().getType();
- if (!mlir::isa<cir::IntType, cir::BoolType, cir::CIRFPTypeInterface,
+ if (!mlir::isa<cir::IntType, cir::BoolType, cir::FPTypeInterface,
mlir::IntegerType, cir::VectorType>(type))
return op.emitError() << "operand type not supported yet";
@@ -1601,7 +1601,7 @@ mlir::LogicalResult CIRToLLVMCmpOpLowering::matchAndRewrite(
/* isSigned=*/false);
rewriter.replaceOpWithNewOp<mlir::LLVM::ICmpOp>(
cmpOp, kind, adaptor.getLhs(), adaptor.getRhs());
- } else if (mlir::isa<cir::CIRFPTypeInterface>(type)) {
+ } else if (mlir::isa<cir::FPTypeInterface>(type)) {
mlir::LLVM::FCmpPredicate kind =
convertCmpKindToFCmpPredicate(cmpOp.getKind());
rewriter.replaceOpWithNewOp<mlir::LLVM::FCmpOp>(
@@ -2059,7 +2059,7 @@ mlir::LogicalResult CIRToLLVMVecCmpOpLowering::matchAndRewrite(
op.getLoc(),
convertCmpKindToICmpPredicate(op.getKind(), intType.isSigned()),
adaptor.getLhs(), adaptor.getRhs());
- } else if (mlir::isa<cir::CIRFPTypeInterface>(elementType)) {
+ } else if (mlir::isa<cir::FPTypeInterface>(elementType)) {
bitResult = rewriter.create<mlir::LLVM::FCmpOp>(
op.getLoc(), convertCmpKindToFCmpPredicate(op.getKind()),
adaptor.getLhs(), adaptor.getRhs());
diff --git a/clang/lib/CIR/Lowering/LoweringHelpers.cpp b/clang/lib/CIR/Lowering/LoweringHelpers.cpp
index b4ae9f1909f41..da3fe4412ec2a 100644
--- a/clang/lib/CIR/Lowering/LoweringHelpers.cpp
+++ b/clang/lib/CIR/Lowering/LoweringHelpers.cpp
@@ -138,7 +138,7 @@ lowerConstArrayAttr(cir::ConstArrayAttr constArr,
return convertToDenseElementsAttr<cir::IntAttr, mlir::APInt>(
constArr, dims, type, converter->convertType(type));
- if (mlir::isa<cir::CIRFPTypeInterface>(type))
+ if (mlir::isa<cir::FPTypeInterface>(type))
return convertToDenseElementsAttr<cir::FPAttr, mlir::APFloat>(
constArr, dims, type, converter->convertType(type));
More information about the cfe-commits
mailing list