clang 20.0.0git
CIRBaseBuilder.h
Go to the documentation of this file.
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_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
10#define LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
11
13
14#include "mlir/IR/Builders.h"
15#include "mlir/IR/BuiltinTypes.h"
16#include "mlir/IR/Types.h"
17
18namespace cir {
19
20class CIRBaseBuilderTy : public mlir::OpBuilder {
21
22public:
23 CIRBaseBuilderTy(mlir::MLIRContext &mlirContext)
24 : mlir::OpBuilder(&mlirContext) {}
25
26 cir::PointerType getPointerTo(mlir::Type ty) {
27 return cir::PointerType::get(getContext(), ty);
28 }
29
30 cir::PointerType getVoidPtrTy() {
31 return getPointerTo(cir::VoidType::get(getContext()));
32 }
33
34 mlir::TypedAttr getConstPtrAttr(mlir::Type type, int64_t value) {
35 auto valueAttr = mlir::IntegerAttr::get(
36 mlir::IntegerType::get(type.getContext(), 64), value);
37 return cir::ConstPtrAttr::get(
38 getContext(), mlir::cast<cir::PointerType>(type), valueAttr);
39 }
40};
41
42} // namespace cir
43
44#endif
cir::PointerType getPointerTo(mlir::Type ty)
CIRBaseBuilderTy(mlir::MLIRContext &mlirContext)
mlir::TypedAttr getConstPtrAttr(mlir::Type type, int64_t value)
cir::PointerType getVoidPtrTy()