EDSC printing: handle integer attributes with bitwidth > 64

This came up in post-submit review.  Use LLVM's support for outputting APInt
values directly instead of obtaining a 64-bit integer value from APInt, which
will not work for wider integers.

PiperOrigin-RevId: 235531574
This commit is contained in:
Alex Zinenko 2019-02-25 08:09:34 -08:00 committed by jpienaar
parent 4887e45546
commit ec76f9c8c1
1 changed files with 4 additions and 2 deletions

View File

@ -767,8 +767,10 @@ void mlir::edsc::Expr::print(raw_ostream &os) const {
// sign-extended result for everything but i1 (booleans).
if (this->is_op<ConstantIndexOp>() || this->is_op<ConstantIntOp>()) {
APInt value = getAttribute("value").cast<IntegerAttr>().getValue();
os << (value.getBitWidth() == 1 ? value.getZExtValue()
: value.getSExtValue());
if (value.getBitWidth() == 1)
os << value.getZExtValue();
else
os << value;
return;
}