From 3bbf6ad7dd4cd77e98aa31f0c6bd41ba321b8290 Mon Sep 17 00:00:00 2001 From: benniaobufeijiushiji Date: Wed, 28 Dec 2022 15:04:28 +0800 Subject: [PATCH 1/9] [Pin-gcc-client] Bugfix for ConstOp Support both signed const int and unsigned const int diff --git a/lib/Translate/GimpleToPluginOps.cpp b/lib/Translate/GimpleToPluginOps.cpp index a5380a7..3a71ffe 100644 --- a/lib/Translate/GimpleToPluginOps.cpp +++ b/lib/Translate/GimpleToPluginOps.cpp @@ -812,9 +812,16 @@ Value GimpleToPluginOps::TreeToValue(uint64_t treeId) mlir::Value opValue; switch (TREE_CODE(t)) { case INTEGER_CST : { - unsigned HOST_WIDE_INT init = tree_to_uhwi(t); - // FIXME : AnyAttr! - mlir::Attribute initAttr = builder.getI64IntegerAttr(init); + mlir::Attribute initAttr; + if (tree_fits_shwi_p(t)) { + signed HOST_WIDE_INT sinit = tree_to_shwi(t); + initAttr = builder.getI64IntegerAttr(sinit); + } else if (tree_fits_uhwi_p(t)) { + unsigned HOST_WIDE_INT uinit = tree_to_uhwi(t); + initAttr = builder.getI64IntegerAttr(uinit); + } else { + abort(); + } opValue = builder.create( builder.getUnknownLoc(), treeId, IDefineCode::IntCST, readOnly, initAttr, rPluginType); -- 2.27.0.windows.1