clang 22.0.0git
LoweringHelpers.h
Go to the documentation of this file.
1//====- LoweringHelpers.h - Lowering helper functions ---------------------===//
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// This file declares helper functions for lowering from CIR to LLVM or MLIR.
10//
11//===----------------------------------------------------------------------===//
12#ifndef LLVM_CLANG_CIR_LOWERINGHELPERS_H
13#define LLVM_CLANG_CIR_LOWERINGHELPERS_H
14
15#include "mlir/IR/BuiltinAttributes.h"
16#include "mlir/Transforms/DialectConversion.h"
18
19mlir::DenseElementsAttr
20convertStringAttrToDenseElementsAttr(cir::ConstArrayAttr attr, mlir::Type type);
21
22template <typename StorageTy> StorageTy getZeroInitFromType(mlir::Type ty);
23template <> mlir::APInt getZeroInitFromType(mlir::Type ty);
24template <> mlir::APFloat getZeroInitFromType(mlir::Type ty);
25
26template <typename AttrTy, typename StorageTy>
27void convertToDenseElementsAttrImpl(cir::ConstArrayAttr attr,
29
30template <typename AttrTy, typename StorageTy>
31mlir::DenseElementsAttr
32convertToDenseElementsAttr(cir::ConstArrayAttr attr,
34 mlir::Type type);
35
36std::optional<mlir::Attribute>
37lowerConstArrayAttr(cir::ConstArrayAttr constArr,
38 const mlir::TypeConverter *converter);
39
40mlir::Value getConstAPInt(mlir::OpBuilder &bld, mlir::Location loc,
41 mlir::Type typ, const llvm::APInt &val);
42
43mlir::Value getConst(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ,
44 unsigned val);
45
46mlir::Value createShL(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs);
47
48mlir::Value createAShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs);
49
50mlir::Value createAnd(mlir::OpBuilder &bld, mlir::Value lhs,
51 const llvm::APInt &rhs);
52
53mlir::Value createLShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs);
54#endif
mlir::DenseElementsAttr convertStringAttrToDenseElementsAttr(cir::ConstArrayAttr attr, mlir::Type type)
mlir::Value createLShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs)
mlir::Value createShL(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs)
mlir::Value getConst(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ, unsigned val)
mlir::Value getConstAPInt(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ, const llvm::APInt &val)
mlir::DenseElementsAttr convertToDenseElementsAttr(cir::ConstArrayAttr attr, const llvm::SmallVectorImpl< int64_t > &dims, mlir::Type type)
std::optional< mlir::Attribute > lowerConstArrayAttr(cir::ConstArrayAttr constArr, const mlir::TypeConverter *converter)
mlir::Value createAShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs)
StorageTy getZeroInitFromType(mlir::Type ty)
mlir::Value createAnd(mlir::OpBuilder &bld, mlir::Value lhs, const llvm::APInt &rhs)
void convertToDenseElementsAttrImpl(cir::ConstArrayAttr attr, llvm::SmallVectorImpl< StorageTy > &values)