From 5fe680390fa78f0e85a4f5eeff49a0f12d5d2655 Mon Sep 17 00:00:00 2001 From: Catherine Date: Sun, 12 Jan 2025 07:11:33 +0000 Subject: [PATCH] Various fixes for clang/libc++ build (#1415) * Gowin: add header includes required on libstdc++. * kernel: fix incorrect printf-style format. * himbaechel: add missing `override` qualifiers. * Gowin: remove unnecessary `std::move`. These calls inhibit RVO, a stronger optimization than moving an object. --- common/kernel/command.cc | 3 ++- himbaechel/uarch/example/example.cc | 6 +++--- himbaechel/uarch/gowin/gowin.cc | 7 ++++--- himbaechel/uarch/gowin/pack.cc | 10 ++++++---- himbaechel/uarch/ng-ultra/ng_ultra.cc | 2 +- himbaechel/uarch/xilinx/xilinx.cc | 2 +- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/common/kernel/command.cc b/common/kernel/command.cc index 9dc54afb..d760c0be 100644 --- a/common/kernel/command.cc +++ b/common/kernel/command.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include "command.h" #include "design_utils.h" @@ -459,7 +460,7 @@ void CommandHandler::setupContext(Context *ctx) std::uniform_int_distribution distrib{1}; auto seed = distrib(randDev); ctx->rngstate = seed; - log_info("Generated random seed: %lu\n", seed); + log_info("Generated random seed: %" PRIu64 "\n", seed); } if (vm.count("slack_redist_iter")) { diff --git a/himbaechel/uarch/example/example.cc b/himbaechel/uarch/example/example.cc index cfb2a0b9..4eebb5ba 100644 --- a/himbaechel/uarch/example/example.cc +++ b/himbaechel/uarch/example/example.cc @@ -194,7 +194,7 @@ struct ExampleImpl : HimbaechelAPI } void drawWire(std::vector &g, GraphicElement::style_t style, Loc loc, IdString wire_type, - int32_t tilewire, IdString tile_type) + int32_t tilewire, IdString tile_type) override { GraphicElement el; el.type = GraphicElement::TYPE_LINE; @@ -308,7 +308,7 @@ struct ExampleImpl : HimbaechelAPI } void drawPip(std::vector &g, GraphicElement::style_t style, Loc loc, WireId src, IdString src_type, - int32_t src_id, WireId dst, IdString dst_type, int32_t dst_id) + int32_t src_id, WireId dst, IdString dst_type, int32_t dst_id) override { GraphicElement el; el.type = GraphicElement::TYPE_ARROW; @@ -329,7 +329,7 @@ struct ExampleArch : HimbaechelArch { ExampleArch() : HimbaechelArch("example") {}; bool match_device(const std::string &device) override { return device == "EXAMPLE"; } - std::unique_ptr create(const std::string &device, const dict &args) + std::unique_ptr create(const std::string &device, const dict &args) override { return std::make_unique(); } diff --git a/himbaechel/uarch/gowin/gowin.cc b/himbaechel/uarch/gowin/gowin.cc index 2afbadeb..7ec19123 100644 --- a/himbaechel/uarch/gowin/gowin.cc +++ b/himbaechel/uarch/gowin/gowin.cc @@ -1,4 +1,5 @@ #include +#include #include "himbaechel_api.h" #include "himbaechel_helpers.h" @@ -43,9 +44,9 @@ struct GowinImpl : HimbaechelAPI bool checkPipAvail(PipId pip) const override; // Cluster - bool isClusterStrict(const CellInfo *cell) const { return true; } + bool isClusterStrict(const CellInfo *cell) const override { return true; } bool getClusterPlacement(ClusterId cluster, BelId root_bel, - std::vector> &placement) const; + std::vector> &placement) const override; private: HimbaechelHelpers h; @@ -109,7 +110,7 @@ struct GowinArch : HimbaechelArch bool match_device(const std::string &device) override { return device.size() > 2 && device.substr(0, 2) == "GW"; } - std::unique_ptr create(const std::string &device, const dict &args) + std::unique_ptr create(const std::string &device, const dict &args) override { return std::make_unique(); } diff --git a/himbaechel/uarch/gowin/pack.cc b/himbaechel/uarch/gowin/pack.cc index 7a82f859..125e29e6 100644 --- a/himbaechel/uarch/gowin/pack.cc +++ b/himbaechel/uarch/gowin/pack.cc @@ -1,3 +1,5 @@ +#include + #include "design_utils.h" #include "log.h" #include "nextpnr.h" @@ -1738,7 +1740,7 @@ struct GowinPacker } // always prepend first ALU with carry generator block // three cases: CIN == 0, CIN == 1 and CIN == ? - new_cells.push_back(std::move(alu_add_cin_block(ctx, ci, cin_net))); + new_cells.push_back(alu_add_cin_block(ctx, ci, cin_net)); CellInfo *cin_block_ci = new_cells.back().get(); // CIN block is the cluster root and is always placed in ALU0 // This is a possible place for further optimization @@ -1784,7 +1786,7 @@ struct GowinPacker break; } if (CellTypePort(*cout_net->users.begin()) != cell_alu_cin || cout_net->users.entries() > 1) { - new_cells.push_back(std::move(alu_add_cout_block(ctx, ci, cout_net))); + new_cells.push_back(alu_add_cout_block(ctx, ci, cout_net)); CellInfo *cout_block_ci = new_cells.back().get(); cin_block_ci->constr_children.push_back(cout_block_ci); NPNR_ASSERT(cout_block_ci->cluster == ClusterId()); @@ -1807,7 +1809,7 @@ struct GowinPacker // ALUs are always paired if (alu_chain_len & 1) { // create dummy cell - new_cells.push_back(std::move(alu_add_dummy_block(ctx, ci))); + new_cells.push_back(alu_add_dummy_block(ctx, ci)); CellInfo *dummy_block_ci = new_cells.back().get(); cin_block_ci->constr_children.push_back(dummy_block_ci); NPNR_ASSERT(dummy_block_ci->cluster == ClusterId()); @@ -1907,7 +1909,7 @@ struct GowinPacker // make actual storage cells for (int i = 0; i < 4; ++i) { - new_cells.push_back(std::move(ssram_make_lut(ctx, ci, i))); + new_cells.push_back(ssram_make_lut(ctx, ci, i)); CellInfo *lut_ci = new_cells.back().get(); ci->constr_children.push_back(lut_ci); lut_ci->cluster = ci->name; diff --git a/himbaechel/uarch/ng-ultra/ng_ultra.cc b/himbaechel/uarch/ng-ultra/ng_ultra.cc index f5932e71..109e8e73 100644 --- a/himbaechel/uarch/ng-ultra/ng_ultra.cc +++ b/himbaechel/uarch/ng-ultra/ng_ultra.cc @@ -1060,7 +1060,7 @@ struct NgUltraArch : HimbaechelArch { NgUltraArch() : HimbaechelArch("ng-ultra") {}; bool match_device(const std::string &device) override { return device == "NG-ULTRA"; } - std::unique_ptr create(const std::string &device, const dict &args) + std::unique_ptr create(const std::string &device, const dict &args) override { return std::make_unique(); } diff --git a/himbaechel/uarch/xilinx/xilinx.cc b/himbaechel/uarch/xilinx/xilinx.cc index 229c3e37..87b94d99 100644 --- a/himbaechel/uarch/xilinx/xilinx.cc +++ b/himbaechel/uarch/xilinx/xilinx.cc @@ -569,7 +569,7 @@ struct XilinxArch : HimbaechelArch { XilinxArch() : HimbaechelArch("xilinx") {}; bool match_device(const std::string &device) override { return device.size() > 3 && device.substr(0, 3) == "xc7"; } - std::unique_ptr create(const std::string &device, const dict &args) + std::unique_ptr create(const std::string &device, const dict &args) override { return std::make_unique(); }