forked from OSchip/llvm-project
[fir] Update fir.alloca op
Add pinned attributes and speicifc builders. The pinned attribute helps mark those allocas in OpenMP regions that should not be hoisted out by an alloca hoisting pass. This patch is part of the upstreaming effort from fir-dev branch. Coming from PR: https://github.com/flang-compiler/f18-llvm-project/pull/1065 Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D110815 Co-authored-by: Valentin Clement <clementval@gmail.com>
This commit is contained in:
parent
c15bbdeaff
commit
4cab4f6b1c
|
@ -129,6 +129,7 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
|
|||
TypeAttr:$in_type,
|
||||
OptionalAttr<StrAttr>:$uniq_name,
|
||||
OptionalAttr<StrAttr>:$bindc_name,
|
||||
UnitAttr:$pinned,
|
||||
Variadic<AnyIntegerType>:$typeparams,
|
||||
Variadic<AnyIntegerType>:$shape
|
||||
);
|
||||
|
@ -145,10 +146,23 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
|
|||
CArg<"mlir::ValueRange", "{}">:$shape,
|
||||
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
|
||||
OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
|
||||
"llvm::StringRef":$bindcName, "bool":$pinned,
|
||||
CArg<"mlir::ValueRange", "{}">:$typeparams,
|
||||
CArg<"mlir::ValueRange", "{}">:$shape,
|
||||
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
|
||||
OpBuilder<(ins "mlir::Type":$in_type,
|
||||
OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
|
||||
CArg<"mlir::ValueRange", "{}">:$typeparams,
|
||||
CArg<"mlir::ValueRange", "{}">:$shape,
|
||||
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
|
||||
OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
|
||||
"bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
|
||||
CArg<"mlir::ValueRange", "{}">:$shape,
|
||||
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
|
||||
OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
|
||||
CArg<"mlir::ValueRange", "{}">:$typeparams,
|
||||
CArg<"mlir::ValueRange", "{}">:$shape,
|
||||
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
|
||||
OpBuilder<(ins "mlir::Type":$inType,
|
||||
CArg<"mlir::ValueRange", "{}">:$typeparams,
|
||||
CArg<"mlir::ValueRange", "{}">:$shape,
|
||||
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
|
||||
|
|
|
@ -169,7 +169,18 @@ void fir::AllocaOp::build(mlir::OpBuilder &builder,
|
|||
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
|
||||
auto nameAttr = builder.getStringAttr(uniqName);
|
||||
build(builder, result, wrapAllocaResultType(inType), inType, nameAttr, {},
|
||||
typeparams, shape);
|
||||
/*pinned=*/false, typeparams, shape);
|
||||
result.addAttributes(attributes);
|
||||
}
|
||||
|
||||
void fir::AllocaOp::build(mlir::OpBuilder &builder,
|
||||
mlir::OperationState &result, mlir::Type inType,
|
||||
llvm::StringRef uniqName, bool pinned,
|
||||
mlir::ValueRange typeparams, mlir::ValueRange shape,
|
||||
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
|
||||
auto nameAttr = builder.getStringAttr(uniqName);
|
||||
build(builder, result, wrapAllocaResultType(inType), inType, nameAttr, {},
|
||||
pinned, typeparams, shape);
|
||||
result.addAttributes(attributes);
|
||||
}
|
||||
|
||||
|
@ -183,7 +194,22 @@ void fir::AllocaOp::build(mlir::OpBuilder &builder,
|
|||
auto bindcAttr =
|
||||
bindcName.empty() ? mlir::StringAttr{} : builder.getStringAttr(bindcName);
|
||||
build(builder, result, wrapAllocaResultType(inType), inType, nameAttr,
|
||||
bindcAttr, typeparams, shape);
|
||||
bindcAttr, /*pinned=*/false, typeparams, shape);
|
||||
result.addAttributes(attributes);
|
||||
}
|
||||
|
||||
void fir::AllocaOp::build(mlir::OpBuilder &builder,
|
||||
mlir::OperationState &result, mlir::Type inType,
|
||||
llvm::StringRef uniqName, llvm::StringRef bindcName,
|
||||
bool pinned, mlir::ValueRange typeparams,
|
||||
mlir::ValueRange shape,
|
||||
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
|
||||
auto nameAttr =
|
||||
uniqName.empty() ? mlir::StringAttr{} : builder.getStringAttr(uniqName);
|
||||
auto bindcAttr =
|
||||
bindcName.empty() ? mlir::StringAttr{} : builder.getStringAttr(bindcName);
|
||||
build(builder, result, wrapAllocaResultType(inType), inType, nameAttr,
|
||||
bindcAttr, pinned, typeparams, shape);
|
||||
result.addAttributes(attributes);
|
||||
}
|
||||
|
||||
|
@ -192,6 +218,16 @@ void fir::AllocaOp::build(mlir::OpBuilder &builder,
|
|||
mlir::ValueRange typeparams, mlir::ValueRange shape,
|
||||
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
|
||||
build(builder, result, wrapAllocaResultType(inType), inType, {}, {},
|
||||
/*pinned=*/false, typeparams, shape);
|
||||
result.addAttributes(attributes);
|
||||
}
|
||||
|
||||
void fir::AllocaOp::build(mlir::OpBuilder &builder,
|
||||
mlir::OperationState &result, mlir::Type inType,
|
||||
bool pinned, mlir::ValueRange typeparams,
|
||||
mlir::ValueRange shape,
|
||||
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
|
||||
build(builder, result, wrapAllocaResultType(inType), inType, {}, {}, pinned,
|
||||
typeparams, shape);
|
||||
result.addAttributes(attributes);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue