14#ifndef CLANG_LIB_CIR_ADDRESS_H
15#define CLANG_LIB_CIR_ADDRESS_H
17#include "mlir/IR/Value.h"
20#include "llvm/ADT/PointerIntPair.h"
30 llvm::PointerIntPair<mlir::Value, 1, bool> pointerAndKnownNonNull;
35 mlir::Type elementType;
40 Address(std::nullptr_t) : elementType(nullptr) {}
43 Address(mlir::Value pointer, mlir::Type elementType,
45 : pointerAndKnownNonNull(pointer,
false), elementType(elementType),
46 alignment(alignment) {
47 assert(mlir::isa<cir::PointerType>(pointer.getType()) &&
48 "Expected cir.ptr type");
50 assert(pointer &&
"Pointer cannot be null");
51 assert(elementType &&
"Element type cannot be null");
52 assert(!alignment.
isZero() &&
"Alignment cannot be zero");
54 assert(mlir::cast<cir::PointerType>(pointer.getType()).getPointee() ==
62 assert((!alignment.
isZero() || pointer ==
nullptr) &&
63 "creating valid address with invalid alignment");
68 return pointerAndKnownNonNull.getPointer() !=
nullptr;
83 return pointerAndKnownNonNull.getPointer();
89 assert(
isValid() &&
"pointer isn't valid");
94 assert(mlir::cast<cir::PointerType>(
95 pointerAndKnownNonNull.getPointer().getType())
96 .getPointee() == elementType);
103 assert(mlir::cast<cir::PointerType>(
104 pointerAndKnownNonNull.getPointer().getType())
105 .getPointee() == elementType);
Address withPointer(mlir::Value newPtr) const
Return address with different pointer, but same element type and alignment.
mlir::Value getPointer() const
Address(mlir::Value pointer, clang::CharUnits alignment)
mlir::Type getElementType() const
Address withElementType(CIRGenBuilderTy &builder, mlir::Type ElemTy) const
Return address with different element type, a bitcast pointer, and the same alignment.
clang::CharUnits getAlignment() const
mlir::Value getBasePointer() const
mlir::Type getType() const
Address(mlir::Value pointer, mlir::Type elementType, clang::CharUnits alignment)
OpTy getDefiningOp() const
mlir::Operation * getDefiningOp() const
Get the operation which defines this address.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
PointerType - C99 6.7.5.1 - Pointer Declarators.
U cast(CodeGen::Address addr)