From 3750fd8c57d37a103b698eb7e479a98ccc68bd02 Mon Sep 17 00:00:00 2001 From: benniaobufeijiushiji Date: Sun, 19 Feb 2023 11:48:16 +0800 Subject: [PATCH 6/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 2f46f6f..5ecab75 100644 --- a/lib/Translate/GimpleToPluginOps.cpp +++ b/lib/Translate/GimpleToPluginOps.cpp @@ -840,13 +840,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); - opValue = builder.create( - builder.getUnknownLoc(), treeId, IDefineCode::IntCST, - readOnly, initAttr, rPluginType); - break; + 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(); + } } case MEM_REF : { tree operand0 = TREE_OPERAND(t, 0); -- 2.27.0.windows.1