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 genVerifyDecl = 1;
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,47 +64,23 @@ LogicalResult complex::NumberAttr::verify(
|
||||||
}
|
}
|
||||||
|
|
||||||
void complex::NumberAttr::print(AsmPrinter &printer) const {
|
void complex::NumberAttr::print(AsmPrinter &printer) const {
|
||||||
printer << "<:";
|
printer << "<:" << getType() << " " << getReal() << ", " << getImag() << ">";
|
||||||
printer.printType(getType());
|
|
||||||
printer << " ";
|
|
||||||
printer.printFloat(getReal());
|
|
||||||
printer << ", ";
|
|
||||||
printer.printFloat(getImag());
|
|
||||||
printer << ">";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Attribute complex::NumberAttr::parse(AsmParser &parser, Type odsType) {
|
Attribute complex::NumberAttr::parse(AsmParser &parser, Type odsType) {
|
||||||
if (failed(parser.parseLess()))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
if (failed(parser.parseColon()))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
if (failed(parser.parseType(type)))
|
double real, imag;
|
||||||
return {};
|
if (parser.parseLess() || parser.parseColon() || parser.parseType(type) ||
|
||||||
|
parser.parseFloat(real) || parser.parseComma() ||
|
||||||
double real;
|
parser.parseFloat(imag) || parser.parseGreater())
|
||||||
if (failed(parser.parseFloat(real)))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
if (failed(parser.parseComma()))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
double imag;
|
|
||||||
if (failed(parser.parseFloat(imag)))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
if (failed(parser.parseGreater()))
|
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
bool unused = false;
|
bool unused = false;
|
||||||
auto realFloat = APFloat(real);
|
APFloat realFloat(real);
|
||||||
realFloat.convert(type.cast<FloatType>().getFloatSemantics(),
|
realFloat.convert(type.cast<FloatType>().getFloatSemantics(),
|
||||||
APFloat::rmNearestTiesToEven, &unused);
|
APFloat::rmNearestTiesToEven, &unused);
|
||||||
auto imagFloat = APFloat(imag);
|
APFloat imagFloat(imag);
|
||||||
imagFloat.convert(type.cast<FloatType>().getFloatSemantics(),
|
imagFloat.convert(type.cast<FloatType>().getFloatSemantics(),
|
||||||
APFloat::rmNearestTiesToEven, &unused);
|
APFloat::rmNearestTiesToEven, &unused);
|
||||||
|
|
||||||
return NumberAttr::get(parser.getContext(), realFloat, imagFloat, type);
|
return NumberAttr::get(parser.getContext(), realFloat, imagFloat, type);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue