From 429d37ff41b5a058fdd0b70f23a55170a973c369 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 19 Jun 2020 19:09:43 -0700 Subject: [PATCH] static cast: simplify --- frontends/ast/simplify.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 1d5dd91a7..e2da17c09 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -3484,6 +3484,13 @@ replace_fcall_later:; } } break; + case AST_CAST_SIZE: + if (children.at(0)->type == AST_CONSTANT && children.at(1)->type == AST_CONSTANT) { + int width = children[0]->bitsAsConst().as_int(); + RTLIL::Const val = children[1]->bitsAsConst(width); + newNode = mkconst_bits(val.bits, children[1]->is_signed); + } + break; case AST_CONCAT: string_op = !children.empty(); for (auto it = children.begin(); it != children.end(); it++) { -- 2.30.2