clang-format

This commit is contained in:
Sergiusz Bazanski 2018-07-14 11:10:59 +01:00
parent 9b17fe385c
commit 8ca7a6da25
6 changed files with 80 additions and 169 deletions

View File

@ -21,16 +21,9 @@
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
MutateContext BaseCtx::rwproxy(void) MutateContext BaseCtx::rwproxy(void) { return MutateContext(reinterpret_cast<Arch *>(this)); }
{
return MutateContext(reinterpret_cast<Arch *>(this));
}
ReadContext BaseCtx::rproxy(void) const
{
return ReadContext(reinterpret_cast<const Arch *>(this));
}
ReadContext BaseCtx::rproxy(void) const { return ReadContext(reinterpret_cast<const Arch *>(this)); }
assertion_failure::assertion_failure(std::string msg, std::string expr_str, std::string filename, int line) assertion_failure::assertion_failure(std::string msg, std::string expr_str, std::string filename, int line)
: runtime_error("Assertion failure: " + msg + " (" + filename + ":" + std::to_string(line) + ")"), msg(msg), : runtime_error("Assertion failure: " + msg + " (" + filename + ":" + std::to_string(line) + ")"), msg(msg),

View File

@ -19,6 +19,7 @@
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include <boost/thread/shared_mutex.hpp>
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
#include <stdint.h> #include <stdint.h>
@ -26,7 +27,6 @@
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
#include <boost/thread/shared_mutex.hpp>
#ifndef NEXTPNR_H #ifndef NEXTPNR_H
#define NEXTPNR_H #define NEXTPNR_H
@ -261,6 +261,7 @@ class BaseCtx
friend class MutateContext; friend class MutateContext;
friend class BaseReadCtx; friend class BaseReadCtx;
friend class BaseMutateCtx; friend class BaseMutateCtx;
private: private:
mutable boost::shared_mutex mtx_; mutable boost::shared_mutex mtx_;
@ -311,7 +312,6 @@ public:
// locks can be taken while this one still exists. Ie., the UI can draw // locks can be taken while this one still exists. Ie., the UI can draw
// elements while the PnR is going a RO operation. // elements while the PnR is going a RO operation.
ReadContext rproxy(void) const; ReadContext rproxy(void) const;
}; };
// State-accessing read-only methods that every architecture object should // State-accessing read-only methods that every architecture object should
@ -320,6 +320,7 @@ class BaseReadCtx
{ {
protected: protected:
const BaseCtx *base_; const BaseCtx *base_;
public: public:
BaseReadCtx(const BaseCtx *base) : base_(base) {} BaseReadCtx(const BaseCtx *base) : base_(base) {}
}; };
@ -334,35 +335,17 @@ protected:
public: public:
BaseMutateCtx(BaseCtx *base) : base_(base) {} BaseMutateCtx(BaseCtx *base) : base_(base) {}
void refreshUi(void) void refreshUi(void) { base_->allUiReload = true; }
{
base_->allUiReload = true;
}
void refreshUiFrame(void) void refreshUiFrame(void) { base_->frameUiReload = true; }
{
base_->frameUiReload = true;
}
void refreshUiBel(BelId bel) void refreshUiBel(BelId bel) { base_->belUiReload.insert(bel); }
{
base_->belUiReload.insert(bel);
}
void refreshUiWire(WireId wire) void refreshUiWire(WireId wire) { base_->wireUiReload.insert(wire); }
{
base_->wireUiReload.insert(wire);
}
void refreshUiPip(PipId pip) void refreshUiPip(PipId pip) { base_->pipUiReload.insert(pip); }
{
base_->pipUiReload.insert(pip);
}
void refreshUiGroup(GroupId group) void refreshUiGroup(GroupId group) { base_->groupUiReload.insert(group); }
{
base_->groupUiReload.insert(group);
}
UIUpdatesRequired getUIUpdatesRequired(void) UIUpdatesRequired getUIUpdatesRequired(void)
{ {
@ -394,12 +377,11 @@ NEXTPNR_NAMESPACE_BEGIN
class ReadContext : public ArchReadMethods class ReadContext : public ArchReadMethods
{ {
friend class BaseCtx; friend class BaseCtx;
private: private:
boost::shared_mutex *lock_; boost::shared_mutex *lock_;
ReadContext(const Arch *parent) : ArchReadMethods(parent), lock_(&parent->mtx_) ReadContext(const Arch *parent) : ArchReadMethods(parent), lock_(&parent->mtx_) { lock_->lock_shared(); }
{
lock_->lock_shared();
}
public: public:
~ReadContext() ~ReadContext()
{ {
@ -407,22 +389,21 @@ public:
lock_->unlock_shared(); lock_->unlock_shared();
} }
} }
ReadContext(ReadContext &&other): ArchReadMethods(other), lock_(other.lock_) ReadContext(ReadContext &&other) : ArchReadMethods(other), lock_(other.lock_) { other.lock_ = nullptr; }
{
other.lock_ = nullptr;
}
}; };
// Read proxy to access MutateMethods while holding lock on underlying BaseCtx. // Read proxy to access MutateMethods while holding lock on underlying BaseCtx.
class MutateContext : public ArchReadMethods, public ArchMutateMethods class MutateContext : public ArchReadMethods, public ArchMutateMethods
{ {
friend class BaseCtx; friend class BaseCtx;
private: private:
boost::shared_mutex *lock_; boost::shared_mutex *lock_;
MutateContext(Arch *parent) : ArchReadMethods(parent), ArchMutateMethods(parent), lock_(&parent->mtx_) MutateContext(Arch *parent) : ArchReadMethods(parent), ArchMutateMethods(parent), lock_(&parent->mtx_)
{ {
lock_->lock(); lock_->lock();
} }
public: public:
~MutateContext() ~MutateContext()
{ {
@ -436,7 +417,6 @@ public:
} }
}; };
struct Context : Arch struct Context : Arch
{ {
bool verbose = false; bool verbose = false;

View File

@ -29,8 +29,7 @@ NEXTPNR_NAMESPACE_BEGIN
typedef int64_t wirelen_t; typedef int64_t wirelen_t;
// Get the total estimated wirelength for a net // Get the total estimated wirelength for a net
template <typename T> template <typename T> wirelen_t get_net_wirelength(const T &proxy, const Context *ctx, const NetInfo *net, float &tns)
wirelen_t get_net_wirelength(const T &proxy, const Context *ctx, const NetInfo *net, float &tns)
{ {
wirelen_t wirelength = 0; wirelen_t wirelength = 0;
int driver_x, driver_y; int driver_x, driver_y;
@ -81,8 +80,7 @@ wirelen_t get_net_wirelength(const T &proxy, const Context *ctx, const NetInfo *
} }
// Return the wirelength of all nets connected to a cell // Return the wirelength of all nets connected to a cell
template <typename T> template <typename T> wirelen_t get_cell_wirelength(const T &proxy, const Context *ctx, const CellInfo *cell)
wirelen_t get_cell_wirelength(const T &proxy, const Context *ctx, const CellInfo *cell)
{ {
std::set<IdString> nets; std::set<IdString> nets;
for (auto p : cell->ports) { for (auto p : cell->ports) {

View File

@ -136,7 +136,6 @@ struct Router
int thisVisitCnt = 0; int thisVisitCnt = 0;
int thisVisitCntLimit = 0; int thisVisitCntLimit = 0;
while (!queue.empty() && (thisVisitCntLimit == 0 || thisVisitCnt < thisVisitCntLimit)) { while (!queue.empty() && (thisVisitCntLimit == 0 || thisVisitCnt < thisVisitCntLimit)) {
QueuedWire qw = queue.top(); QueuedWire qw = queue.top();
queue.pop(); queue.pop();

View File

@ -259,99 +259,43 @@ BelRange Arch::getBelsAtSameTile(BelId bel) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Shorthands to ArchProxy // Shorthands to ArchProxy
BelId Arch::getBelByName(IdString name) const BelId Arch::getBelByName(IdString name) const { return rproxy().getBelByName(name); }
{
return rproxy().getBelByName(name);
}
void Arch::bindWire(WireId wire, IdString net, PlaceStrength strength) void Arch::bindWire(WireId wire, IdString net, PlaceStrength strength) { rwproxy().bindWire(wire, net, strength); }
{
rwproxy().bindWire(wire, net, strength);
}
void Arch::unbindWire(WireId wire) void Arch::unbindWire(WireId wire) { rwproxy().unbindWire(wire); }
{
rwproxy().unbindWire(wire);
}
void Arch::bindBel(BelId bel, IdString cell, PlaceStrength strength) { void Arch::bindBel(BelId bel, IdString cell, PlaceStrength strength) { rwproxy().bindBel(bel, cell, strength); }
rwproxy().bindBel(bel, cell, strength);
}
void Arch::unbindBel(BelId bel) void Arch::unbindBel(BelId bel) { rwproxy().unbindBel(bel); }
{
rwproxy().unbindBel(bel);
}
bool Arch::checkBelAvail(BelId bel) const bool Arch::checkBelAvail(BelId bel) const { return rproxy().checkBelAvail(bel); }
{
return rproxy().checkBelAvail(bel);
}
IdString Arch::getBoundBelCell(BelId bel) const IdString Arch::getBoundBelCell(BelId bel) const { return rproxy().getBoundBelCell(bel); }
{
return rproxy().getBoundBelCell(bel);
}
IdString Arch::getConflictingBelCell(BelId bel) const IdString Arch::getConflictingBelCell(BelId bel) const { return rproxy().getConflictingBelCell(bel); }
{
return rproxy().getConflictingBelCell(bel);
}
WireId Arch::getWireByName(IdString name) const WireId Arch::getWireByName(IdString name) const { return rproxy().getWireByName(name); }
{
return rproxy().getWireByName(name);
}
WireId Arch::getWireBelPin(BelId bel, PortPin pin) const WireId Arch::getWireBelPin(BelId bel, PortPin pin) const { return rproxy().getWireBelPin(bel, pin); }
{
return rproxy().getWireBelPin(bel, pin);
}
bool Arch::checkWireAvail(WireId wire) const bool Arch::checkWireAvail(WireId wire) const { return rproxy().checkWireAvail(wire); }
{
return rproxy().checkWireAvail(wire);
}
IdString Arch::getBoundWireNet(WireId wire) const IdString Arch::getBoundWireNet(WireId wire) const { return rproxy().getBoundWireNet(wire); }
{
return rproxy().getBoundWireNet(wire);
}
IdString Arch::getConflictingWireNet(WireId wire) const IdString Arch::getConflictingWireNet(WireId wire) const { return rproxy().getConflictingWireNet(wire); }
{
return rproxy().getConflictingWireNet(wire);
}
PipId Arch::getPipByName(IdString name) const PipId Arch::getPipByName(IdString name) const { return rproxy().getPipByName(name); }
{
return rproxy().getPipByName(name);
}
void Arch::bindPip(PipId pip, IdString net, PlaceStrength strength) void Arch::bindPip(PipId pip, IdString net, PlaceStrength strength) { return rwproxy().bindPip(pip, net, strength); }
{
return rwproxy().bindPip(pip, net, strength);
}
void Arch::unbindPip(PipId pip) void Arch::unbindPip(PipId pip) { return rwproxy().unbindPip(pip); }
{
return rwproxy().unbindPip(pip);
}
bool Arch::checkPipAvail(PipId pip) const bool Arch::checkPipAvail(PipId pip) const { return rproxy().checkPipAvail(pip); }
{
return rproxy().checkPipAvail(pip);
}
IdString Arch::getBoundPipNet(PipId pip) const IdString Arch::getBoundPipNet(PipId pip) const { return rproxy().getBoundPipNet(pip); }
{
return rproxy().getBoundPipNet(pip);
}
IdString Arch::getConflictingPipNet(PipId pip) const IdString Arch::getConflictingPipNet(PipId pip) const { return rproxy().getConflictingPipNet(pip); }
{
return rproxy().getConflictingPipNet(pip);
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -630,8 +574,7 @@ std::vector<GraphicElement> ArchReadMethods::getDecalGraphics(DecalId decal) con
} }
if (bel_type == TYPE_ICESTORM_RAM) { if (bel_type == TYPE_ICESTORM_RAM) {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++) {
{
int tx = chip_info->bel_data[bel.index].x; int tx = chip_info->bel_data[bel.index].x;
int ty = chip_info->bel_data[bel.index].y + i; int ty = chip_info->bel_data[bel.index].y + i;
@ -936,9 +879,6 @@ void ArchMutateMethods::unbindPip(PipId pip)
refreshUiWire(dst); refreshUiWire(dst);
} }
CellInfo *ArchMutateMethods::getCell(IdString cell) CellInfo *ArchMutateMethods::getCell(IdString cell) { return parent_->cells.at(cell).get(); }
{
return parent_->cells.at(cell).get();
}
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -343,6 +343,7 @@ class Arch : public BaseCtx
// We let proxy methods access our state. // We let proxy methods access our state.
friend class ArchMutateMethods; friend class ArchMutateMethods;
friend class ArchReadMethods; friend class ArchReadMethods;
private: private:
// All of the following... // All of the following...
std::vector<IdString> bel_to_cell; std::vector<IdString> bel_to_cell;
@ -410,10 +411,7 @@ public:
return id(chip_info->bel_data[bel.index].name.get()); return id(chip_info->bel_data[bel.index].name.get());
} }
uint32_t getBelChecksum(BelId bel) const uint32_t getBelChecksum(BelId bel) const { return bel.index; }
{
return bel.index;
}
BelRange getBels() const BelRange getBels() const
{ {
@ -445,7 +443,6 @@ public:
return chip_info->bel_data[bel.index].type; return chip_info->bel_data[bel.index].type;
} }
BelPin getBelPinUphill(WireId wire) const BelPin getBelPinUphill(WireId wire) const
{ {
BelPin ret; BelPin ret;
@ -549,7 +546,6 @@ public:
return range; return range;
} }
BelId getPackagePinBel(const std::string &pin) const; BelId getPackagePinBel(const std::string &pin) const;
std::string getBelPackagePin(BelId bel) const; std::string getBelPackagePin(BelId bel) const;
@ -611,7 +607,8 @@ public:
}; };
// Read-only methods on Arch that require state access. // Read-only methods on Arch that require state access.
class ArchReadMethods : public BaseReadCtx { class ArchReadMethods : public BaseReadCtx
{
private: private:
const Arch *parent_; const Arch *parent_;
const ChipInfoPOD *chip_info; const ChipInfoPOD *chip_info;
@ -625,12 +622,13 @@ private:
public: public:
~ArchReadMethods() noexcept {} ~ArchReadMethods() noexcept {}
ArchReadMethods(const Arch *parent) : BaseReadCtx(parent), parent_(parent), ArchReadMethods(const Arch *parent)
chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell), : BaseReadCtx(parent), parent_(parent), chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell),
wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net), wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net),
switches_locked(parent->switches_locked), switches_locked(parent->switches_locked), bel_by_name(parent->bel_by_name),
bel_by_name(parent->bel_by_name), wire_by_name(parent->wire_by_name), wire_by_name(parent->wire_by_name), pip_by_name(parent->pip_by_name)
pip_by_name(parent->pip_by_name) {} {
}
ArchReadMethods(ArchReadMethods &&other) noexcept : ArchReadMethods(other.parent_) {} ArchReadMethods(ArchReadMethods &&other) noexcept : ArchReadMethods(other.parent_) {}
ArchReadMethods(const ArchReadMethods &other) : ArchReadMethods(other.parent_) {} ArchReadMethods(const ArchReadMethods &other) : ArchReadMethods(other.parent_) {}
@ -669,8 +667,10 @@ public:
}; };
// State mutating methods on Arch. // State mutating methods on Arch.
class ArchMutateMethods : public BaseMutateCtx { class ArchMutateMethods : public BaseMutateCtx
{
friend class MutateContext; friend class MutateContext;
private: private:
Arch *parent_; Arch *parent_;
const ChipInfoPOD *chip_info; const ChipInfoPOD *chip_info;
@ -683,12 +683,13 @@ private:
std::unordered_map<IdString, int> &pip_by_name; std::unordered_map<IdString, int> &pip_by_name;
public: public:
ArchMutateMethods(Arch *parent) : BaseMutateCtx(parent), parent_(parent), ArchMutateMethods(Arch *parent)
chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell), : BaseMutateCtx(parent), parent_(parent), chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell),
wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net), wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net),
switches_locked(parent->switches_locked), switches_locked(parent->switches_locked), bel_by_name(parent->bel_by_name),
bel_by_name(parent->bel_by_name), wire_by_name(parent->wire_by_name), wire_by_name(parent->wire_by_name), pip_by_name(parent->pip_by_name)
pip_by_name(parent->pip_by_name) {} {
}
ArchMutateMethods(ArchMutateMethods &&other) : ArchMutateMethods(other.parent_) {} ArchMutateMethods(ArchMutateMethods &&other) : ArchMutateMethods(other.parent_) {}
ArchMutateMethods(const ArchMutateMethods &other) : ArchMutateMethods(other.parent_) {} ArchMutateMethods(const ArchMutateMethods &other) : ArchMutateMethods(other.parent_) {}
~ArchMutateMethods() {} ~ArchMutateMethods() {}