1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H
10 #define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H
12 #include "CIRGenTypeCache.h"
14 #include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
16 namespace clang::CIRGen
{
18 class CIRGenBuilderTy
: public cir::CIRBaseBuilderTy
{
19 const CIRGenTypeCache
&typeCache
;
22 CIRGenBuilderTy(mlir::MLIRContext
&mlirContext
, const CIRGenTypeCache
&tc
)
23 : CIRBaseBuilderTy(mlirContext
), typeCache(tc
) {}
25 cir::LongDoubleType
getLongDoubleTy(const llvm::fltSemantics
&format
) const {
26 if (&format
== &llvm::APFloat::IEEEdouble())
27 return cir::LongDoubleType::get(getContext(), typeCache
.DoubleTy
);
28 if (&format
== &llvm::APFloat::x87DoubleExtended())
29 return cir::LongDoubleType::get(getContext(), typeCache
.FP80Ty
);
30 if (&format
== &llvm::APFloat::IEEEquad())
31 return cir::LongDoubleType::get(getContext(), typeCache
.FP128Ty
);
32 if (&format
== &llvm::APFloat::PPCDoubleDouble())
33 llvm_unreachable("NYI: PPC double-double format for long double");
34 llvm_unreachable("Unsupported format for long double");
38 } // namespace clang::CIRGen