14#ifndef CLANG_LIB_CIR_ADDRESS_H
15#define CLANG_LIB_CIR_ADDRESS_H
17#include "mlir/IR/Value.h"
21#include "llvm/ADT/PointerIntPair.h"
31 llvm::PointerIntPair<mlir::Value, 1, bool> pointerAndKnownNonNull;
36 mlir::Type elementType;
44 Address(mlir::Value pointer, mlir::Type elementType,
46 : pointerAndKnownNonNull(pointer,
false), elementType(elementType),
47 alignment(alignment) {
48 assert(pointer &&
"Pointer cannot be null");
49 assert(elementType &&
"Element type cannot be null");
50 assert(!alignment.isZero() &&
"Alignment cannot be zero");
52 assert(mlir::isa<cir::PointerType>(pointer.getType()) &&
53 "Expected cir.ptr type");
55 assert(mlir::cast<cir::PointerType>(pointer.getType()).getPointee() ==
63 assert((!alignment.isZero() || pointer ==
nullptr) &&
64 "creating valid address with invalid alignment");
69 return pointerAndKnownNonNull.getPointer() !=
nullptr;
84 return pointerAndKnownNonNull.getPointer();
90 assert(
isValid() &&
"pointer isn't valid");
102 assert(mlir::cast<cir::PointerType>(
103 pointerAndKnownNonNull.getPointer().getType())
104 .getPointee() == elementType);
111 assert(mlir::cast<cir::PointerType>(
112 pointerAndKnownNonNull.getPointer().getType())
113 .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.
mlir::Value emitRawPointer() const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
CharUnits - This is an opaque type for sizes expressed in character units.
PointerType - C99 6.7.5.1 - Pointer Declarators.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
U cast(CodeGen::Address addr)
static bool addressPointerAuthInfo()