1 //===----------------------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H 10 #define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H 11 12 #include "CIRGenTypeCache.h" 13 14 #include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h" 15 16 namespace clang::CIRGen { 17 18 class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { 19 const CIRGenTypeCache &typeCache; 20 21 public: 22 CIRGenBuilderTy(mlir::MLIRContext &mlirContext, const CIRGenTypeCache &tc) 23 : CIRBaseBuilderTy(mlirContext), typeCache(tc) {} 24 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"); 35 } 36 }; 37 38 } // namespace clang::CIRGen 39 40 #endif 41