forked from OSchip/llvm-project
[mlir] Small stylistic changes to Complex_NumberAttr
Differential Revision: https://reviews.llvm.org/D130632
This commit is contained in:
parent
c78144e1c7
commit
824954a8c9
|
@ -34,8 +34,9 @@ def Complex_NumberAttr : Complex_Attr<"Number", "number"> {
|
|||
```
|
||||
}];
|
||||
|
||||
let parameters = (ins APFloatParameter<"">:$real, APFloatParameter<"">:$imag, AttributeSelfTypeParameter<"">:$type);
|
||||
|
||||
let parameters = (ins APFloatParameter<"">:$real,
|
||||
APFloatParameter<"">:$imag,
|
||||
AttributeSelfTypeParameter<"">:$type);
|
||||
let genVerifyDecl = 1;
|
||||
let hasCustomAssemblyFormat = 1;
|
||||
}
|
||||
|
|
|
@ -64,47 +64,23 @@ LogicalResult complex::NumberAttr::verify(
|
|||
}
|
||||
|
||||
void complex::NumberAttr::print(AsmPrinter &printer) const {
|
||||
printer << "<:";
|
||||
printer.printType(getType());
|
||||
printer << " ";
|
||||
printer.printFloat(getReal());
|
||||
printer << ", ";
|
||||
printer.printFloat(getImag());
|
||||
printer << ">";
|
||||
printer << "<:" << getType() << " " << getReal() << ", " << getImag() << ">";
|
||||
}
|
||||
|
||||
Attribute complex::NumberAttr::parse(AsmParser &parser, Type odsType) {
|
||||
if (failed(parser.parseLess()))
|
||||
return {};
|
||||
|
||||
if (failed(parser.parseColon()))
|
||||
return {};
|
||||
|
||||
Type type;
|
||||
if (failed(parser.parseType(type)))
|
||||
return {};
|
||||
|
||||
double real;
|
||||
if (failed(parser.parseFloat(real)))
|
||||
return {};
|
||||
|
||||
if (failed(parser.parseComma()))
|
||||
return {};
|
||||
|
||||
double imag;
|
||||
if (failed(parser.parseFloat(imag)))
|
||||
return {};
|
||||
|
||||
if (failed(parser.parseGreater()))
|
||||
double real, imag;
|
||||
if (parser.parseLess() || parser.parseColon() || parser.parseType(type) ||
|
||||
parser.parseFloat(real) || parser.parseComma() ||
|
||||
parser.parseFloat(imag) || parser.parseGreater())
|
||||
return {};
|
||||
|
||||
bool unused = false;
|
||||
auto realFloat = APFloat(real);
|
||||
APFloat realFloat(real);
|
||||
realFloat.convert(type.cast<FloatType>().getFloatSemantics(),
|
||||
APFloat::rmNearestTiesToEven, &unused);
|
||||
auto imagFloat = APFloat(imag);
|
||||
APFloat imagFloat(imag);
|
||||
imagFloat.convert(type.cast<FloatType>().getFloatSemantics(),
|
||||
APFloat::rmNearestTiesToEven, &unused);
|
||||
|
||||
return NumberAttr::get(parser.getContext(), realFloat, imagFloat, type);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue