19#ifndef FORTRAN_OPTIMIZER_BUILDER_TEMPORARYSTORAGE_H
20#define FORTRAN_OPTIMIZER_BUILDER_TEMPORARYSTORAGE_H
22#include "flang/Optimizer/HLFIR/HLFIROps.h"
32namespace fir::factory {
47 mlir::Value initialValue,
bool canCountThroughLoops =
true);
53 const bool canCountThroughLoops;
57 mlir::Value initialValue;
71 fir::SequenceType declaredType, mlir::Value extent,
73 bool allocateOnHeap,
bool stackThroughLoops,
74 llvm::StringRef name);
94 const bool allocateOnHeap;
109 assert(
false &&
"must not be called: value already set");
113 return copy.getBase();
116 bool canBeFetchedAfterPush()
const {
return true; }
140 bool canBeFetchedAfterPush()
const {
return true; }
155 mlir::Type valueStaticType);
162 bool canBeFetchedAfterPush()
const {
return true; }
167 mlir::Type valueStaticType;
170 mlir::Value opaquePtr;
174 mlir::Value retValueBox;
185 mlir::Type valueStaticType);
192 bool canBeFetchedAfterPush()
const {
return true; }
196 mlir::Type variableStaticType;
199 mlir::Value opaquePtr;
203 mlir::Value retValueBox;
216 mlir::Type valueStaticType,
217 bool shapeCanBeSavedAsRegister,
int rank);
223 bool canBeFetchedAfterPush()
const {
return true; }
226 std::unique_ptr<TemporaryStorage> shapeTemp;
229 std::optional<mlir::Type> boxType;
235 template <
typename T>
240 std::visit([&](
auto &temp) { temp.pushValue(loc, builder, value); }, impl);
243 std::visit([&](
auto &temp) { temp.resetFetchPosition(loc, builder); },
247 return std::visit([&](
auto &temp) {
return temp.fetch(loc, builder); },
251 std::visit([&](
auto &temp) { temp.destroy(loc, builder); }, impl);
256 return std::visit([&](
auto &temp) {
return temp.canBeFetchedAfterPush(); },
260 template <
typename T>
262 return std::get<T>(impl);
266 std::variant<HomogeneousScalarStack, SimpleCopy, SSARegister, AnyValueStack,
267 AnyVariableStack, AnyVectorSubscriptStack>
Definition: FIRBuilder.h:55
Definition: TemporaryStorage.h:152
Definition: TemporaryStorage.h:182
Definition: TemporaryStorage.h:213
Definition: TemporaryStorage.h:68
hlfir::Entity moveStackAsArrayExpr(mlir::Location loc, fir::FirOpBuilder &builder)
Definition: TemporaryStorage.cpp:132
bool canBeFetchedAfterPush() const
Definition: TemporaryStorage.h:90
Definition: TemporaryStorage.h:127
mlir::Value ssaRegister
Temporary storage for the copy.
Definition: TemporaryStorage.h:144
Structure to hold the value of a single entity.
Definition: TemporaryStorage.h:102
hlfir::AssociateOp copy
Temporary storage for the copy.
Definition: TemporaryStorage.h:120
Generic wrapper over the different sorts of temporary storages.
Definition: TemporaryStorage.h:233
bool canBeFetchedAfterPush() const
Definition: TemporaryStorage.h:255
Definition: HLFIRTools.h:51
Definition: AbstractConverter.h:31
Definition: TemporaryStorage.h:44
void reset(mlir::Location loc, fir::FirOpBuilder &builder)
Set the counter to the initial value.
Definition: TemporaryStorage.cpp:52
mlir::Value getAndIncrementIndex(mlir::Location loc, fir::FirOpBuilder &builder)
Return "counter++".
Definition: TemporaryStorage.cpp:38