Run "make clangformat".

Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
Keith Rothman 2021-02-01 14:28:32 -08:00
parent 01509ec7c9
commit da74a425d2
22 changed files with 174 additions and 210 deletions

View File

@ -112,17 +112,17 @@ fn_wrapper_2a_v<Context, decltype(&Context::writeSVG), &Context::writeSVG, pass_
pass_through<std::string>>::def_wrap(ctx_cls, "writeSVG");
// const\_range\<BelBucketId\> getBelBuckets() const
fn_wrapper_0a<Context, decltype(&Context::getBelBuckets), &Context::getBelBuckets, wrap_context<BelBucketRange>>::def_wrap(ctx_cls,
"getBelBuckets");
fn_wrapper_0a<Context, decltype(&Context::getBelBuckets), &Context::getBelBuckets,
wrap_context<BelBucketRange>>::def_wrap(ctx_cls, "getBelBuckets");
// BelBucketId getBelBucketForBel(BelId bel) const
fn_wrapper_1a<Context, decltype(&Context::getBelBucketForBel), &Context::getBelBucketForBel, conv_to_str<BelBucketId>,
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelBucketForBel");
// BelBucketId getBelBucketForCellType(IdString cell\_type) const
fn_wrapper_1a<Context, decltype(&Context::getBelBucketForCellType), &Context::getBelBucketForCellType, conv_to_str<BelBucketId>,
conv_from_str<IdString>>::def_wrap(ctx_cls, "getBelBucketForCellType");
fn_wrapper_1a<Context, decltype(&Context::getBelBucketForCellType), &Context::getBelBucketForCellType,
conv_to_str<BelBucketId>, conv_from_str<IdString>>::def_wrap(ctx_cls, "getBelBucketForCellType");
// const\_range\<BelId\> getBelsInBucket(BelBucketId bucket) const
fn_wrapper_1a<Context, decltype(&Context::getBelsInBucket), &Context::getBelsInBucket, wrap_context<BelRangeForBelBucket>,
conv_from_str<BelBucketId>>::def_wrap(ctx_cls, "getBelsInBucket");
fn_wrapper_1a<Context, decltype(&Context::getBelsInBucket), &Context::getBelsInBucket,
wrap_context<BelRangeForBelBucket>, conv_from_str<BelBucketId>>::def_wrap(ctx_cls, "getBelsInBucket");
// bool isValidBelForCellType(IdString cell\_type, BelId bel) const
fn_wrapper_2a<Context, decltype(&Context::isValidBelForCellType), &Context::isValidBelForCellType, pass_through<bool>,
conv_from_str<IdString>, conv_from_str<BelId>>::def_wrap(ctx_cls, "isValidBelForCellType");

View File

@ -20,22 +20,28 @@
#pragma once
#include "nextpnr.h"
#include <cstddef>
#include "nextpnr.h"
NEXTPNR_NAMESPACE_BEGIN
// FastBels is a lookup class that provides a fast lookup for finding BELs
// that support a given cell type.
struct FastBels {
struct TypeData {
struct FastBels
{
struct TypeData
{
size_t type_index;
int number_of_possible_bels;
};
FastBels(Context *ctx, bool check_bel_available, int minBelsForGridPick) : ctx(ctx), check_bel_available(check_bel_available), minBelsForGridPick(minBelsForGridPick) {}
FastBels(Context *ctx, bool check_bel_available, int minBelsForGridPick)
: ctx(ctx), check_bel_available(check_bel_available), minBelsForGridPick(minBelsForGridPick)
{
}
void addCellType(IdString cell_type) {
void addCellType(IdString cell_type)
{
auto iter = cell_types.find(cell_type);
if (iter != cell_types.end()) {
// This cell type has already been added to the fast BEL lookup.
@ -83,7 +89,8 @@ struct FastBels {
}
}
void addBelBucket(BelBucketId partition) {
void addBelBucket(BelBucketId partition)
{
auto iter = partition_types.find(partition);
if (iter != partition_types.end()) {
// This partition has already been added to the fast BEL lookup.
@ -133,7 +140,8 @@ struct FastBels {
typedef std::vector<std::vector<std::vector<BelId>>> FastBelsData;
int getBelsForCellType(IdString cell_type, FastBelsData **data) {
int getBelsForCellType(IdString cell_type, FastBelsData **data)
{
auto iter = cell_types.find(cell_type);
if (iter == cell_types.end()) {
addCellType(cell_type);
@ -147,7 +155,8 @@ struct FastBels {
return cell_type_data.number_of_possible_bels;
}
size_t getBelsForBelBucket(BelBucketId partition, FastBelsData **data) {
size_t getBelsForBelBucket(BelBucketId partition, FastBelsData **data)
{
auto iter = partition_types.find(partition);
if (iter == partition_types.end()) {
addBelBucket(partition);

View File

@ -118,7 +118,8 @@ bool place_single_cell(Context *ctx, CellInfo *cell, bool require_legality)
}
IdString targetType = cell->type;
for (auto bel : ctx->getBels()) {
if (ctx->isValidBelForCellType(targetType, bel) && (!require_legality || ctx->isValidBelForCell(cell, bel))) {
if (ctx->isValidBelForCellType(targetType, bel) &&
(!require_legality || ctx->isValidBelForCell(cell, bel))) {
if (ctx->checkBelAvail(bel)) {
wirelen_t wirelen = get_cell_metric_at_bel(ctx, cell, bel, MetricType::COST);
if (iters >= 4)

View File

@ -39,11 +39,11 @@
#include <stdlib.h>
#include <string.h>
#include <vector>
#include "fast_bels.h"
#include "log.h"
#include "place_common.h"
#include "timing.h"
#include "util.h"
#include "fast_bels.h"
namespace std {
template <> struct hash<std::pair<NEXTPNR_NAMESPACE_PREFIX IdString, std::size_t>>
@ -76,7 +76,8 @@ class SAPlacer
};
public:
SAPlacer(Context *ctx, Placer1Cfg cfg) : ctx(ctx), fast_bels(ctx, /*check_bel_available=*/false, cfg.minBelsForGridPick), cfg(cfg)
SAPlacer(Context *ctx, Placer1Cfg cfg)
: ctx(ctx), fast_bels(ctx, /*check_bel_available=*/false, cfg.minBelsForGridPick), cfg(cfg)
{
for (auto bel : ctx->getBels()) {
Loc loc = ctx->getBelLocation(bel);

View File

@ -44,13 +44,13 @@
#include <queue>
#include <tuple>
#include <unordered_map>
#include "fast_bels.h"
#include "log.h"
#include "nextpnr.h"
#include "place_common.h"
#include "placer1.h"
#include "timing.h"
#include "util.h"
#include "fast_bels.h"
NEXTPNR_NAMESPACE_BEGIN
@ -138,7 +138,10 @@ template <typename T> struct EquationSystem
class HeAPPlacer
{
public:
HeAPPlacer(Context *ctx, PlacerHeapCfg cfg) : ctx(ctx), cfg(cfg), fast_bels(ctx, /*check_bel_available=*/true, -1) { Eigen::initParallel(); }
HeAPPlacer(Context *ctx, PlacerHeapCfg cfg) : ctx(ctx), cfg(cfg), fast_bels(ctx, /*check_bel_available=*/true, -1)
{
Eigen::initParallel();
}
bool place()
{
@ -532,8 +535,7 @@ class HeAPPlacer
// all.
if (!available_bels.count(ci->type)) {
log_error("Unable to place cell '%s', no BELs remaining to implement cell type '%s'\n",
ci->name.c_str(ctx),
ci->type.c_str(ctx));
ci->name.c_str(ctx), ci->type.c_str(ctx));
}
// Find an unused BEL from bels_for_cell_type.
@ -542,8 +544,7 @@ class HeAPPlacer
while (true) {
if (bels_for_cell_type.empty()) {
log_error("Unable to place cell '%s', no BELs remaining to implement cell type '%s'\n",
ci->name.c_str(ctx),
ci->type.c_str(ctx));
ci->name.c_str(ctx), ci->type.c_str(ctx));
}
BelId candidate_bel = bels_for_cell_type.back();
@ -1202,13 +1203,12 @@ class HeAPPlacer
return int(fb.at(type)->at(x).at(y).size());
}
bool is_cell_fixed(const CellInfo & cell) const {
bool is_cell_fixed(const CellInfo &cell) const
{
return buckets.count(ctx->getBelBucketForCellType(cell.type)) == 0;
}
size_t cell_index(const CellInfo & cell) const {
return type_index.at(ctx->getBelBucketForCellType(cell.type));
}
size_t cell_index(const CellInfo &cell) const { return type_index.at(ctx->getBelBucketForCellType(cell.type)); }
void init()
{
@ -1476,8 +1476,7 @@ class HeAPPlacer
if (reg.cells > reg.bels) {
IdString bucket_name = ctx->getBelBucketName(bucket);
log_error("Failed to expand region (%d, %d) |_> (%d, %d) of %d %ss\n", reg.x0, reg.y0,
reg.x1, reg.y1, reg.cells.at(type_index.at(bucket)),
bucket_name.c_str(ctx));
reg.x1, reg.y1, reg.cells.at(type_index.at(bucket)), bucket_name.c_str(ctx));
}
}
break;

View File

@ -950,41 +950,37 @@ struct Arch : BaseCtx
// -------------------------------------------------
// Placement validity checks
bool isValidBelForCellType(IdString cell_type, BelId bel) const {
return cell_type == getBelType(bel);
}
bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
const std::vector<IdString> &getCellTypes() const {
return cell_types;
}
const std::vector<IdString> &getCellTypes() const { return cell_types; }
std::vector<BelBucketId> getBelBuckets() const {
return buckets;
}
std::vector<BelBucketId> getBelBuckets() const { return buckets; }
IdString getBelBucketName(BelBucketId bucket) const {
return bucket.name;
}
IdString getBelBucketName(BelBucketId bucket) const { return bucket.name; }
BelBucketId getBelBucketByName(IdString name) const {
BelBucketId getBelBucketByName(IdString name) const
{
BelBucketId bucket;
bucket.name = name;
return bucket;
}
BelBucketId getBelBucketForBel(BelId bel) const {
BelBucketId getBelBucketForBel(BelId bel) const
{
BelBucketId bucket;
bucket.name = getBelType(bel);
return bucket;
}
BelBucketId getBelBucketForCellType(IdString cell_type) const {
BelBucketId getBelBucketForCellType(IdString cell_type) const
{
BelBucketId bucket;
bucket.name = cell_type;
return bucket;
}
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const {
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const
{
std::vector<BelId> bels;
for (BelId bel : getBels()) {
if (getBelType(bel) == bucket.name) {

View File

@ -126,15 +126,13 @@ struct PipId
}
};
struct BelBucketId {
struct BelBucketId
{
IdString name;
bool operator==(const BelBucketId &other) const { return (name == other.name); }
bool operator!=(const BelBucketId &other) const { return (name != other.name); }
bool operator<(const BelBucketId &other) const
{
return name < other.name;
}
bool operator<(const BelBucketId &other) const { return name < other.name; }
};
struct GroupId

View File

@ -271,7 +271,8 @@ struct Arch : BaseCtx
bool place();
bool route();
std::vector<IdString> getCellTypes() const {
std::vector<IdString> getCellTypes() const
{
std::vector<IdString> cell_types;
cell_types.reserve(bels.size());
for (auto bel : bels) {
@ -281,27 +282,18 @@ struct Arch : BaseCtx
return cell_types;
}
std::vector<BelBucketId> getBelBuckets() const {
return getCellTypes();
}
std::vector<BelBucketId> getBelBuckets() const { return getCellTypes(); }
IdString getBelBucketName(BelBucketId bucket) const {
return bucket;
}
IdString getBelBucketName(BelBucketId bucket) const { return bucket; }
BelBucketId getBelBucketByName(IdString bucket) const {
return bucket;
}
BelBucketId getBelBucketByName(IdString bucket) const { return bucket; }
BelBucketId getBelBucketForBel(BelId bel) const {
return getBelType(bel);
}
BelBucketId getBelBucketForBel(BelId bel) const { return getBelType(bel); }
BelBucketId getBelBucketForCellType(IdString cell_type) const {
return cell_type;
}
BelBucketId getBelBucketForCellType(IdString cell_type) const { return cell_type; }
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const {
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const
{
std::vector<BelId> bels;
for (BelId bel : getBels()) {
if (bucket == getBelBucketForBel(bel)) {
@ -323,9 +315,7 @@ struct Arch : BaseCtx
// Get the TimingClockingInfo of a port
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const;
bool isValidBelForCellType(IdString cell_type, BelId bel) const {
return cell_type == getBelType(bel);
}
bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
bool isValidBelForCell(CellInfo *cell, BelId bel) const;
bool isBelLocationValid(BelId bel) const;

View File

@ -227,30 +227,26 @@ void arch_wrap_python(py::module &m)
"clock"_a, "clktoq"_a);
// const\_range\<BelBucketId\> getBelBuckets() const
fn_wrapper_0a<Context, decltype(&Context::getBelBuckets),
&Context::getBelBuckets,
fn_wrapper_0a<Context, decltype(&Context::getBelBuckets), &Context::getBelBuckets,
wrap_context<const std::vector<BelBucketId> &>>::def_wrap(ctx_cls, "getBelBuckets");
// BelBucketId getBelBucketForBel(BelId bel) const
fn_wrapper_1a<Context, decltype(&Context::getBelBucketForBel),
&Context::getBelBucketForBel, conv_to_str<BelBucketId>,
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelBucketForBel");
fn_wrapper_1a<Context, decltype(&Context::getBelBucketForBel), &Context::getBelBucketForBel,
conv_to_str<BelBucketId>, conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelBucketForBel");
// BelBucketId getBelBucketForCellType(IdString cell\_type) const
fn_wrapper_1a<Context, decltype(&Context::getBelBucketForCellType),
&Context::getBelBucketForCellType, conv_to_str<BelBucketId>,
conv_from_str<IdString>>::def_wrap(ctx_cls, "getBelBucketForCellType");
fn_wrapper_1a<Context, decltype(&Context::getBelBucketForCellType), &Context::getBelBucketForCellType,
conv_to_str<BelBucketId>, conv_from_str<IdString>>::def_wrap(ctx_cls, "getBelBucketForCellType");
// const\_range\<BelId\> getBelsInBucket(BelBucketId bucket) const
fn_wrapper_1a<Context, decltype(&Context::getBelsInBucket),
&Context::getBelsInBucket, wrap_context<const std::vector<BelId> &>,
conv_from_str<BelBucketId>>::def_wrap(ctx_cls, "getBelsInBucket");
fn_wrapper_1a<Context, decltype(&Context::getBelsInBucket), &Context::getBelsInBucket,
wrap_context<const std::vector<BelId> &>, conv_from_str<BelBucketId>>::def_wrap(ctx_cls,
"getBelsInBucket");
// bool isValidBelForCellType(IdString cell\_type, BelId bel) const
fn_wrapper_2a<Context, decltype(&Context::isValidBelForCellType),
&Context::isValidBelForCellType, pass_through<bool>,
conv_from_str<IdString>, conv_from_str<BelId>>::def_wrap(
ctx_cls, "isValidBelForCellType");
fn_wrapper_2a<Context, decltype(&Context::isValidBelForCellType), &Context::isValidBelForCellType,
pass_through<bool>, conv_from_str<IdString>, conv_from_str<BelId>>::def_wrap(ctx_cls,
"isValidBelForCellType");
WRAP_MAP_UPTR(m, CellMap, "IdCellMap");
WRAP_MAP_UPTR(m, NetMap, "IdNetMap");

View File

@ -422,35 +422,22 @@ struct Arch : BaseCtx
// Get the TimingClockingInfo of a port
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const;
bool isValidBelForCellType(IdString cell_type, BelId bel) const {
return cell_type == getBelType(bel);
}
bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
const std::vector<IdString> &getCellTypes() const {
return cell_types;
}
const std::vector<IdString> &getCellTypes() const { return cell_types; }
std::vector<BelBucketId> getBelBuckets() const {
return cell_types;
}
std::vector<BelBucketId> getBelBuckets() const { return cell_types; }
IdString getBelBucketName(BelBucketId bucket) const {
return bucket;
}
IdString getBelBucketName(BelBucketId bucket) const { return bucket; }
BelBucketId getBelBucketByName(IdString name) const {
return name;
}
BelBucketId getBelBucketByName(IdString name) const { return name; }
BelBucketId getBelBucketForBel(BelId bel) const {
return getBelType(bel);
}
BelBucketId getBelBucketForBel(BelId bel) const { return getBelType(bel); }
BelBucketId getBelBucketForCellType(IdString cell_type) const {
return cell_type;
}
BelBucketId getBelBucketForCellType(IdString cell_type) const { return cell_type; }
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const {
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const
{
std::vector<BelId> bels;
for (BelId bel : getBels()) {
if (getBelType(bel) == bucket) {

View File

@ -822,41 +822,37 @@ struct Arch : BaseCtx
// implemented in arch_place.cc)
// Whether this cell type can be placed at this BEL.
bool isValidBelForCellType(IdString cell_type, BelId bel) const {
return cell_type == getBelType(bel);
}
bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
const std::vector<IdString> &getCellTypes() const {
return cell_types;
}
const std::vector<IdString> &getCellTypes() const { return cell_types; }
std::vector<BelBucketId> getBelBuckets() const {
return buckets;
}
std::vector<BelBucketId> getBelBuckets() const { return buckets; }
IdString getBelBucketName(BelBucketId bucket) const {
return bucket.name;
}
IdString getBelBucketName(BelBucketId bucket) const { return bucket.name; }
BelBucketId getBelBucketByName(IdString name) const {
BelBucketId getBelBucketByName(IdString name) const
{
BelBucketId bucket;
bucket.name = name;
return bucket;
}
BelBucketId getBelBucketForBel(BelId bel) const {
BelBucketId getBelBucketForBel(BelId bel) const
{
BelBucketId bucket;
bucket.name = getBelType(bel);
return bucket;
}
BelBucketId getBelBucketForCellType(IdString cell_type) const {
BelBucketId getBelBucketForCellType(IdString cell_type) const
{
BelBucketId bucket;
bucket.name = cell_type;
return bucket;
}
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const {
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const
{
std::vector<BelId> bels;
for (BelId bel : getBels()) {
if (getBelType(bel) == bucket.name) {

View File

@ -85,7 +85,6 @@ void arch_wrap_python(py::module &m)
WRAP_RANGE(m, Pip, conv_to_str<PipId>);
WRAP_RANGE(m, BelPin, wrap_context<BelPin>);
WRAP_MAP_UPTR(m, CellMap, "IdCellMap");
WRAP_MAP_UPTR(m, NetMap, "IdNetMap");
WRAP_MAP(m, HierarchyMap, wrap_context<HierarchicalCell &>, "HierarchyMap");

View File

@ -170,15 +170,13 @@ struct ArchCellInfo
};
};
struct BelBucketId {
struct BelBucketId
{
IdString name;
bool operator==(const BelBucketId &other) const { return (name == other.name); }
bool operator!=(const BelBucketId &other) const { return (name != other.name); }
bool operator<(const BelBucketId &other) const
{
return name < other.name;
}
bool operator<(const BelBucketId &other) const { return name < other.name; }
};
NEXTPNR_NAMESPACE_END

View File

@ -1336,41 +1336,37 @@ struct Arch : BaseCtx
// implemented in arch_place.cc)
// Whether this cell type can be placed at this BEL.
bool isValidBelForCellType(IdString cell_type, BelId bel) const {
return cell_type == getBelType(bel);
}
bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
const std::vector<IdString> &getCellTypes() const {
return cell_types;
}
const std::vector<IdString> &getCellTypes() const { return cell_types; }
std::vector<BelBucketId> getBelBuckets() const {
return buckets;
}
std::vector<BelBucketId> getBelBuckets() const { return buckets; }
IdString getBelBucketName(BelBucketId bucket) const {
return bucket.name;
}
IdString getBelBucketName(BelBucketId bucket) const { return bucket.name; }
BelBucketId getBelBucketByName(IdString name) const {
BelBucketId getBelBucketByName(IdString name) const
{
BelBucketId bucket;
bucket.name = name;
return bucket;
}
BelBucketId getBelBucketForBel(BelId bel) const {
BelBucketId getBelBucketForBel(BelId bel) const
{
BelBucketId bucket;
bucket.name = getBelType(bel);
return bucket;
}
BelBucketId getBelBucketForCellType(IdString cell_type) const {
BelBucketId getBelBucketForCellType(IdString cell_type) const
{
BelBucketId bucket;
bucket.name = cell_type;
return bucket;
}
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const {
std::vector<BelId> getBelsInBucket(BelBucketId bucket) const
{
std::vector<BelId> bels;
for (BelId bel : getBels()) {
if (getBelType(bel) == bucket.name) {

View File

@ -114,15 +114,13 @@ struct PipId
}
};
struct BelBucketId {
struct BelBucketId
{
IdString name;
bool operator==(const BelBucketId &other) const { return (name == other.name); }
bool operator!=(const BelBucketId &other) const { return (name != other.name); }
bool operator<(const BelBucketId &other) const
{
return name < other.name;
}
bool operator<(const BelBucketId &other) const { return name < other.name; }
};
struct GroupId