Skip to content

Commit 512b4b5

Browse files
committed
[CIR] Follow-up to floating-point upstream change
Fix the opening comment on some newly added files. Add asserts that the Clang types `float` and `double` are IEEE 32-bit and 64-bit.
1 parent b76111a commit 512b4b5

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
//===- CIRFPTypeInterface.td - CIR FP Interface Definitions -----*- C++ -*-===//
1+
//===----------------------------------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8+
//
9+
// Defines the interface to generically handle CIR floating-point types.
10+
//
11+
//===----------------------------------------------------------------------===//
812

913
#ifndef LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_TD
1014
#define LLVM_CLANG_INCLUDE_CLANG_CIR_INTERFACES_CIRFPTYPEINTERFACE_TD

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bool CIRGenTypes::isFuncParamTypeConvertible(clang::QualType type) {
3030
// certain circumstances have been reached.
3131
assert(!type->getAs<MemberPointerType>() && "NYI");
3232

33-
// If this isn't a tagged type, we can convert it!
33+
// If this isn't a tag type, we can convert it.
3434
const TagType *tagType = type->getAs<TagType>();
3535
if (!tagType)
3636
return true;
@@ -171,9 +171,15 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
171171
resultType = cgm.BFloat16Ty;
172172
break;
173173
case BuiltinType::Float:
174+
assert(&astContext.getFloatTypeSemantics(type) ==
175+
&llvm::APFloat::IEEEsingle() &&
176+
"ClangIR only supports float as IEEE 32-bit");
174177
resultType = cgm.FloatTy;
175178
break;
176179
case BuiltinType::Double:
180+
assert(&astContext.getFloatTypeSemantics(type) ==
181+
&llvm::APFloat::IEEEdouble() &&
182+
"ClangIR only supports double as IEEE 64-bit");
177183
resultType = cgm.DoubleTy;
178184
break;
179185
case BuiltinType::LongDouble:

clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
//====- CIRFPTypeInterface.cpp - Interface for floating-point types -------===//
1+
//===----------------------------------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8+
//
9+
// Defines the interface to generically handle CIR floating-point types.
10+
//
11+
//===----------------------------------------------------------------------===//
812

913
#include "clang/CIR/Interfaces/CIRFPTypeInterface.h"
1014

0 commit comments

Comments
 (0)