[flang-commits] [flang] be80c6d - [flang][NFC] Cosmetic changes to make the file more homogenous
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Wed Jun 29 05:21:24 PDT 2022
Author: Valentin Clement
Date: 2022-06-29T14:21:19+02:00
New Revision: be80c6d1b16922ad324c0dea0db9dca836fd3c50
URL: https://github.com/llvm/llvm-project/commit/be80c6d1b16922ad324c0dea0db9dca836fd3c50
DIFF: https://github.com/llvm/llvm-project/commit/be80c6d1b16922ad324c0dea0db9dca836fd3c50.diff
LOG: [flang][NFC] Cosmetic changes to make the file more homogenous
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D128799
Added:
Modified:
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Optimizer/Dialect/FIROps.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 6dc6bae6afde9..e7d8fa4fa214a 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -280,46 +280,6 @@ def fir_LoadOp : fir_OneResultOp<"load", [MemoryEffects<[MemRead]>]> {
}];
}
-def fir_CharConvertOp : fir_Op<"char_convert", []> {
- let summary = [{
- Primitive to convert an entity of type CHARACTER from one KIND to a
-
diff erent KIND.
- }];
-
- let description = [{
- Copy a CHARACTER (must be in memory) of KIND _k1_ to a CHARACTER (also must
- be in memory) of KIND _k2_ where _k1_ != _k2_ and the buffers do not
- overlap. This latter restriction is unchecked, as the Fortran language
- definition eliminates the overlapping in memory case.
-
- The number of code points copied is specified explicitly as the second
- argument. The length of the !fir.char type is ignored.
-
- ```mlir
- fir.char_convert %1 for %2 to %3 : !fir.ref<!fir.char<1,?>>, i32,
- !fir.ref<!fir.char<2,20>>
- ```
-
- Should future support for encodings other than ASCII be supported, codegen
- can generate a call to a runtime helper routine which will map the code
- points from UTF-8 to UCS-2, for example. Such remappings may not always
- be possible as they may involve the creation of more code points than the
- `count` limit. These details are left as future to-dos.
- }];
-
- let arguments = (ins
- Arg<AnyReferenceLike, "", [MemRead]>:$from,
- AnyIntegerType:$count,
- Arg<AnyReferenceLike, "", [MemWrite]>:$to
- );
-
- let assemblyFormat = [{
- $from `for` $count `to` $to attr-dict `:` type(operands)
- }];
-
- let hasVerifier = 1;
-}
-
def fir_StoreOp : fir_Op<"store", [MemoryEffects<[MemWrite]>]> {
let summary = "store an SSA-value to a memory location";
@@ -357,7 +317,7 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
let description = [{
Save the result of a function returning an array, box, or record type value
- into a memory location given the shape and length parameters of the result.
+ into a memory location given the shape and LEN parameters of the result.
Function results of type fir.box, fir.array, or fir.rec are abstract values
that require a storage to be manipulated on the caller side. This operation
@@ -366,8 +326,8 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
memory.
For arrays, result, it is required to provide the shape of the result. For
- character arrays and derived types with length parameters, the length
- parameter values must be provided.
+ character arrays and derived types with LEN parameters, the LEN parameter
+ values must be provided.
The fir.save_result associated to a function call must immediately follow
the call and be in the same block.
@@ -399,6 +359,46 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
let hasVerifier = 1;
}
+def fir_CharConvertOp : fir_Op<"char_convert", []> {
+ let summary = [{
+ Primitive to convert an entity of type CHARACTER from one KIND to a
+
diff erent KIND.
+ }];
+
+ let description = [{
+ Copy a CHARACTER (must be in memory) of KIND _k1_ to a CHARACTER (also must
+ be in memory) of KIND _k2_ where _k1_ != _k2_ and the buffers do not
+ overlap. This latter restriction is unchecked, as the Fortran language
+ definition eliminates the overlapping in memory case.
+
+ The number of code points copied is specified explicitly as the second
+ argument. The length of the !fir.char type is ignored.
+
+ ```mlir
+ fir.char_convert %1 for %2 to %3 : !fir.ref<!fir.char<1,?>>, i32,
+ !fir.ref<!fir.char<2,20>>
+ ```
+
+ Should future support for encodings other than ASCII be supported, codegen
+ can generate a call to a runtime helper routine which will map the code
+ points from UTF-8 to UCS-2, for example. Such remappings may not always
+ be possible as they may involve the creation of more code points than the
+ `count` limit. These details are left as future to-dos.
+ }];
+
+ let arguments = (ins
+ Arg<AnyReferenceLike, "", [MemRead]>:$from,
+ AnyIntegerType:$count,
+ Arg<AnyReferenceLike, "", [MemWrite]>:$to
+ );
+
+ let assemblyFormat = [{
+ $from `for` $count `to` $to attr-dict `:` type(operands)
+ }];
+
+ let hasVerifier = 1;
+}
+
def fir_UndefOp : fir_OneResultOp<"undefined", [NoSideEffect]> {
let summary = "explicit undefined value of some type";
let description = [{
@@ -2353,7 +2353,7 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
// operand[0] is the object (of box type)
operand_iterator arg_operand_begin() { return operand_begin() + 1; }
operand_iterator arg_operand_end() { return operand_end(); }
- static constexpr llvm::StringRef passArgAttrName() {
+ static constexpr llvm::StringRef getPassArgAttrName() {
return "pass_arg_pos";
}
static constexpr llvm::StringRef getMethodAttrNameStr() { return "method"; }
@@ -2446,11 +2446,11 @@ def fir_ConstcOp : fir_Op<"constc", [NoSideEffect]> {
let hasVerifier = 1;
let extraClassDeclaration = [{
- static constexpr llvm::StringRef realAttrName() { return "real"; }
- static constexpr llvm::StringRef imagAttrName() { return "imaginary"; }
+ static constexpr llvm::StringRef getRealAttrName() { return "real"; }
+ static constexpr llvm::StringRef getImagAttrName() { return "imaginary"; }
- mlir::Attribute getReal() { return (*this)->getAttr(realAttrName()); }
- mlir::Attribute getImaginary() { return (*this)->getAttr(imagAttrName()); }
+ mlir::Attribute getReal() { return (*this)->getAttr(getRealAttrName()); }
+ mlir::Attribute getImaginary() { return (*this)->getAttr(getImagAttrName()); }
}];
}
@@ -2677,11 +2677,13 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
];
let extraClassDeclaration = [{
- static constexpr llvm::StringRef symbolAttrNameStr() { return "symref"; }
+ static constexpr llvm::StringRef getSymbolAttrNameStr() { return "symref"; }
static constexpr llvm::StringRef getConstantAttrNameStr() {
return "constant";
}
- static constexpr llvm::StringRef linkageAttrName() { return "linkName"; }
+ static constexpr llvm::StringRef getLinkageAttrNameStr() {
+ return "linkName";
+ }
/// The semantic type of the global
mlir::Type resultType();
@@ -2733,8 +2735,8 @@ def fir_GlobalLenOp : fir_Op<"global_len", []> {
let hasCustomAssemblyFormat = 1;
let extraClassDeclaration = [{
- static constexpr llvm::StringRef lenParamAttrName() { return "lenparam"; }
- static constexpr llvm::StringRef intAttrName() { return "intval"; }
+ static constexpr llvm::StringRef getLenParamAttrName() { return "lenparam"; }
+ static constexpr llvm::StringRef getIntAttrName() { return "intval"; }
}];
}
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 4b863f9b87347..8d0868dc5f035 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -798,10 +798,10 @@ mlir::ParseResult fir::ConstcOp::parse(mlir::OpAsmParser &parser,
fir::RealAttr imagp;
mlir::Type type;
if (parser.parseLParen() ||
- parser.parseAttribute(realp, fir::ConstcOp::realAttrName(),
+ parser.parseAttribute(realp, fir::ConstcOp::getRealAttrName(),
result.attributes) ||
parser.parseComma() ||
- parser.parseAttribute(imagp, fir::ConstcOp::imagAttrName(),
+ parser.parseAttribute(imagp, fir::ConstcOp::getImagAttrName(),
result.attributes) ||
parser.parseRParen() || parser.parseColonType(type) ||
parser.addTypesToList(type, result.types))
@@ -811,8 +811,8 @@ mlir::ParseResult fir::ConstcOp::parse(mlir::OpAsmParser &parser,
void fir::ConstcOp::print(mlir::OpAsmPrinter &p) {
p << '(';
- p << getOperation()->getAttr(fir::ConstcOp::realAttrName()) << ", ";
- p << getOperation()->getAttr(fir::ConstcOp::imagAttrName()) << ") : ";
+ p << getOperation()->getAttr(fir::ConstcOp::getRealAttrName()) << ", ";
+ p << getOperation()->getAttr(fir::ConstcOp::getImagAttrName()) << ") : ";
p.printType(getType());
}
@@ -1218,12 +1218,12 @@ mlir::ParseResult fir::GlobalOp::parse(mlir::OpAsmParser &parser,
if (fir::GlobalOp::verifyValidLinkage(linkage))
return mlir::failure();
mlir::StringAttr linkAttr = builder.getStringAttr(linkage);
- result.addAttribute(fir::GlobalOp::linkageAttrName(), linkAttr);
+ result.addAttribute(fir::GlobalOp::getLinkageAttrNameStr(), linkAttr);
}
// Parse the name as a symbol reference attribute.
mlir::SymbolRefAttr nameAttr;
- if (parser.parseAttribute(nameAttr, fir::GlobalOp::symbolAttrNameStr(),
+ if (parser.parseAttribute(nameAttr, fir::GlobalOp::getSymbolAttrNameStr(),
result.attributes))
return mlir::failure();
result.addAttribute(mlir::SymbolTable::getSymbolAttrName(),
@@ -1294,7 +1294,7 @@ void fir::GlobalOp::build(mlir::OpBuilder &builder,
result.addAttribute(getTypeAttrName(result.name), mlir::TypeAttr::get(type));
result.addAttribute(mlir::SymbolTable::getSymbolAttrName(),
builder.getStringAttr(name));
- result.addAttribute(symbolAttrNameStr(),
+ result.addAttribute(getSymbolAttrNameStr(),
mlir::SymbolRefAttr::get(builder.getContext(), name));
if (isConstant)
result.addAttribute(getConstantAttrName(result.name),
@@ -1302,7 +1302,7 @@ void fir::GlobalOp::build(mlir::OpBuilder &builder,
if (initialVal)
result.addAttribute(getInitValAttrName(result.name), initialVal);
if (linkage)
- result.addAttribute(linkageAttrName(), linkage);
+ result.addAttribute(getLinkageAttrNameStr(), linkage);
result.attributes.append(attrs.begin(), attrs.end());
}
@@ -1359,24 +1359,25 @@ mlir::ParseResult fir::GlobalLenOp::parse(mlir::OpAsmParser &parser,
llvm::StringRef fieldName;
if (failed(parser.parseOptionalKeyword(&fieldName))) {
mlir::StringAttr fieldAttr;
- if (parser.parseAttribute(fieldAttr, fir::GlobalLenOp::lenParamAttrName(),
+ if (parser.parseAttribute(fieldAttr,
+ fir::GlobalLenOp::getLenParamAttrName(),
result.attributes))
return mlir::failure();
} else {
- result.addAttribute(fir::GlobalLenOp::lenParamAttrName(),
+ result.addAttribute(fir::GlobalLenOp::getLenParamAttrName(),
parser.getBuilder().getStringAttr(fieldName));
}
mlir::IntegerAttr constant;
if (parser.parseComma() ||
- parser.parseAttribute(constant, fir::GlobalLenOp::intAttrName(),
+ parser.parseAttribute(constant, fir::GlobalLenOp::getIntAttrName(),
result.attributes))
return mlir::failure();
return mlir::success();
}
void fir::GlobalLenOp::print(mlir::OpAsmPrinter &p) {
- p << ' ' << getOperation()->getAttr(fir::GlobalLenOp::lenParamAttrName())
- << ", " << getOperation()->getAttr(fir::GlobalLenOp::intAttrName());
+ p << ' ' << getOperation()->getAttr(fir::GlobalLenOp::getLenParamAttrName())
+ << ", " << getOperation()->getAttr(fir::GlobalLenOp::getIntAttrName());
}
//===----------------------------------------------------------------------===//
More information about the flang-commits
mailing list