Internals: Update to clang-format-11 (#3021)
This commit is contained in:
parent
2705715bb1
commit
c75a686081
|
|
@ -27,14 +27,14 @@ jobs:
|
||||||
CI_BUILD_STAGE_NAME: build
|
CI_BUILD_STAGE_NAME: build
|
||||||
run: |
|
run: |
|
||||||
bash ci/ci-install.bash &&
|
bash ci/ci-install.bash &&
|
||||||
sudo apt-get install clang-10 yapf3 &&
|
sudo apt-get install clang-format-11 yapf3 &&
|
||||||
git config --global user.email "action@example.com" &&
|
git config --global user.email "action@example.com" &&
|
||||||
git config --global user.name "github action"
|
git config --global user.name "github action"
|
||||||
- name: Format code
|
- name: Format code
|
||||||
run: |
|
run: |
|
||||||
autoconf &&
|
autoconf &&
|
||||||
./configure &&
|
./configure &&
|
||||||
make -j 2 format CLANGFORMAT=clang-format-10 &&
|
make -j 2 format CLANGFORMAT=clang-format-11 &&
|
||||||
git status
|
git status
|
||||||
- name: Push
|
- name: Push
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -470,13 +470,13 @@ analyzer-include:
|
||||||
|
|
||||||
format: clang-format yapf format-pl-exec
|
format: clang-format yapf format-pl-exec
|
||||||
|
|
||||||
CLANGFORMAT = clang-format
|
CLANGFORMAT = clang-format-11
|
||||||
CLANGFORMAT_FLAGS = -i
|
CLANGFORMAT_FLAGS = -i
|
||||||
CLANGFORMAT_FILES = $(CPPCHECK_CPP) $(CPPCHECK_H) $(CPPCHECK_YL) test_regress/t/*.c* test_regress/t/*.h
|
CLANGFORMAT_FILES = $(CPPCHECK_CPP) $(CPPCHECK_H) $(CPPCHECK_YL) test_regress/t/*.c* test_regress/t/*.h
|
||||||
|
|
||||||
clang-format:
|
clang-format:
|
||||||
@$(CLANGFORMAT) --version | egrep 10.0 > /dev/null \
|
@$(CLANGFORMAT) --version | egrep 11.0 > /dev/null \
|
||||||
|| echo "*** You are not using clang-format 10.0, indents may differ from master's ***"
|
|| echo "*** You are not using clang-format 11.0, indents may differ from master's ***"
|
||||||
$(CLANGFORMAT) $(CLANGFORMAT_FLAGS) $(CLANGFORMAT_FILES)
|
$(CLANGFORMAT) $(CLANGFORMAT_FLAGS) $(CLANGFORMAT_FILES)
|
||||||
|
|
||||||
PY_PROGRAMS = \
|
PY_PROGRAMS = \
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ Those developing Verilator itself may also want these (see internals.rst):
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
sudo apt-get install gdb graphviz cmake clang clang-format gprof lcov
|
sudo apt-get install gdb graphviz cmake clang clang-format-11 gprof lcov
|
||||||
sudo pip3 install sphinx sphinx_rtd_theme breathe
|
sudo pip3 install sphinx sphinx_rtd_theme breathe
|
||||||
cpan install Pod::Perldoc
|
cpan install Pod::Perldoc
|
||||||
cpan install Parallel::Forker
|
cpan install Parallel::Forker
|
||||||
|
|
|
||||||
|
|
@ -152,30 +152,34 @@ public:
|
||||||
const VerilatedRange& unpacked() const { return m_unpacked[0]; }
|
const VerilatedRange& unpacked() const { return m_unpacked[0]; }
|
||||||
// DPI accessors
|
// DPI accessors
|
||||||
int left(int dim) const {
|
int left(int dim) const {
|
||||||
return dim == 0 ? m_packed.left()
|
return dim == 0 ? m_packed.left()
|
||||||
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].left() : 0;
|
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].left()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
int right(int dim) const {
|
int right(int dim) const {
|
||||||
return dim == 0 ? m_packed.right()
|
return dim == 0 ? m_packed.right()
|
||||||
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].right() : 0;
|
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].right()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
int low(int dim) const {
|
int low(int dim) const {
|
||||||
return dim == 0 ? m_packed.low()
|
return dim == 0 ? m_packed.low()
|
||||||
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].low() : 0;
|
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].low()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
int high(int dim) const {
|
int high(int dim) const {
|
||||||
return dim == 0 ? m_packed.high()
|
return dim == 0 ? m_packed.high()
|
||||||
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].high() : 0;
|
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].high()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
int increment(int dim) const {
|
int increment(int dim) const {
|
||||||
return dim == 0
|
return dim == 0 ? m_packed.increment()
|
||||||
? m_packed.increment()
|
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].increment()
|
||||||
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].increment() : 0;
|
: 0;
|
||||||
}
|
}
|
||||||
int elements(int dim) const {
|
int elements(int dim) const {
|
||||||
return dim == 0
|
return dim == 0 ? m_packed.elements()
|
||||||
? m_packed.elements()
|
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].elements()
|
||||||
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].elements() : 0;
|
: 0;
|
||||||
}
|
}
|
||||||
// Total size in bytes (note DPI limited to 4GB)
|
// Total size in bytes (note DPI limited to 4GB)
|
||||||
size_t totalSize() const;
|
size_t totalSize() const;
|
||||||
|
|
|
||||||
|
|
@ -5428,9 +5428,9 @@ public:
|
||||||
: (m_urandom ? "%f$urandom()" : "%f$random()");
|
: (m_urandom ? "%f$urandom()" : "%f$random()");
|
||||||
}
|
}
|
||||||
virtual string emitC() override {
|
virtual string emitC() override {
|
||||||
return m_reset
|
return m_reset ? "VL_RAND_RESET_%nq(%nw, %P)"
|
||||||
? "VL_RAND_RESET_%nq(%nw, %P)"
|
: seedp() ? "VL_RANDOM_SEEDED_%nq%lq(%nw, %P, %li)"
|
||||||
: seedp() ? "VL_RANDOM_SEEDED_%nq%lq(%nw, %P, %li)" : "VL_RANDOM_%nq(%nw, %P)";
|
: "VL_RANDOM_%nq(%nw, %P)";
|
||||||
}
|
}
|
||||||
virtual bool cleanOut() const override { return true; }
|
virtual bool cleanOut() const override { return true; }
|
||||||
virtual bool isGateOptimizable() const override { return false; }
|
virtual bool isGateOptimizable() const override { return false; }
|
||||||
|
|
|
||||||
|
|
@ -110,13 +110,11 @@ class EmitCConstPool final : EmitCBaseVisitor {
|
||||||
UASSERT_OBJ(dtypep, nodep, "Array initializer has non-array dtype");
|
UASSERT_OBJ(dtypep, nodep, "Array initializer has non-array dtype");
|
||||||
const uint32_t size = dtypep->elementsConst();
|
const uint32_t size = dtypep->elementsConst();
|
||||||
const uint32_t elemBytes = dtypep->subDTypep()->widthTotalBytes();
|
const uint32_t elemBytes = dtypep->subDTypep()->widthTotalBytes();
|
||||||
const uint32_t tabMod = dtypep->subDTypep()->isString()
|
const uint32_t tabMod = dtypep->subDTypep()->isString() ? 1 // String
|
||||||
? 1 // String
|
: elemBytes <= 2 ? 8 // CData, SData
|
||||||
: elemBytes <= 2
|
: elemBytes <= 4 ? 4 // IData
|
||||||
? 8 // CData, SData
|
: elemBytes <= 8 ? 2 // QData
|
||||||
: elemBytes <= 4 ? 4 // IData
|
: 1;
|
||||||
: elemBytes <= 8 ? 2 // QData
|
|
||||||
: 1;
|
|
||||||
VL_RESTORER(m_inUnpacked);
|
VL_RESTORER(m_inUnpacked);
|
||||||
VL_RESTORER(m_unpackedWord);
|
VL_RESTORER(m_unpackedWord);
|
||||||
m_inUnpacked = true;
|
m_inUnpacked = true;
|
||||||
|
|
|
||||||
|
|
@ -134,10 +134,10 @@ public:
|
||||||
return (na() ? "yellow" : epsilon() ? "green" : "black");
|
return (na() ? "yellow" : epsilon() ? "green" : "black");
|
||||||
}
|
}
|
||||||
virtual string dotLabel() const override {
|
virtual string dotLabel() const override {
|
||||||
return (na() ? ""
|
return (na() ? ""
|
||||||
: epsilon() ? "e"
|
: epsilon() ? "e"
|
||||||
: complement() ? ("not " + cvtToStr(input().toInt()))
|
: complement() ? ("not " + cvtToStr(input().toInt()))
|
||||||
: cvtToStr(input().toInt()));
|
: cvtToStr(input().toInt()));
|
||||||
}
|
}
|
||||||
virtual string dotStyle() const override { return (na() || cutable()) ? "dashed" : ""; }
|
virtual string dotStyle() const override { return (na() || cutable()) ? "dashed" : ""; }
|
||||||
bool epsilon() const { return input().toInt() == EPSILON().toInt(); }
|
bool epsilon() const { return input().toInt() == EPSILON().toInt(); }
|
||||||
|
|
|
||||||
|
|
@ -118,13 +118,11 @@ private:
|
||||||
if (nodep->aboveCellp()) iterate(nodep->aboveCellp());
|
if (nodep->aboveCellp()) iterate(nodep->aboveCellp());
|
||||||
// Always recompute name (as many levels above scope may have changed)
|
// Always recompute name (as many levels above scope may have changed)
|
||||||
// Same formula as V3Scope
|
// Same formula as V3Scope
|
||||||
nodep->name(nodep->isTop()
|
nodep->name(nodep->isTop() ? "TOP"
|
||||||
? "TOP"
|
: VN_IS(m_modp, Class) ? ("TOP." + m_modp->name())
|
||||||
: VN_IS(m_modp, Class) ? ("TOP." + m_modp->name())
|
: VN_IS(m_modp, ClassPackage)
|
||||||
: VN_IS(m_modp, ClassPackage)
|
? ("TOP." + m_modp->name())
|
||||||
? ("TOP." + m_modp->name())
|
: (nodep->aboveScopep()->name() + "." + nodep->aboveCellp()->name()));
|
||||||
: (nodep->aboveScopep()->name() + "."
|
|
||||||
+ nodep->aboveCellp()->name()));
|
|
||||||
nodep->editCountInc();
|
nodep->editCountInc();
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -889,8 +889,9 @@ private:
|
||||||
<< AstNode::prettyNameQ(nodep->cname()));
|
<< AstNode::prettyNameQ(nodep->cname()));
|
||||||
}
|
}
|
||||||
// Tasks (but not void functions) return a boolean 'int' indicating disabled
|
// Tasks (but not void functions) return a boolean 'int' indicating disabled
|
||||||
const string rtnType
|
const string rtnType = rtnvarp ? rtnvarp->dpiArgType(true, true)
|
||||||
= rtnvarp ? rtnvarp->dpiArgType(true, true) : nodep->dpiTask() ? "int" : "";
|
: nodep->dpiTask() ? "int"
|
||||||
|
: "";
|
||||||
AstCFunc* const funcp = new AstCFunc(nodep->fileline(), nodep->cname(), m_scopep, rtnType);
|
AstCFunc* const funcp = new AstCFunc(nodep->fileline(), nodep->cname(), m_scopep, rtnType);
|
||||||
funcp->dpiImportPrototype(true);
|
funcp->dpiImportPrototype(true);
|
||||||
funcp->dontCombine(true);
|
funcp->dontCombine(true);
|
||||||
|
|
|
||||||
|
|
@ -92,12 +92,18 @@ public:
|
||||||
AstNode* nodep() const { return m_nodep; }
|
AstNode* nodep() const { return m_nodep; }
|
||||||
AstVar* varp() const { return VN_CAST(nodep(), Var); }
|
AstVar* varp() const { return VN_CAST(nodep(), Var); }
|
||||||
virtual string name() const override {
|
virtual string name() const override {
|
||||||
return ((isTristate() ? "tri\\n" : feedsTri() ? "feed\\n" : "-\\n")
|
return ((isTristate() ? "tri\\n"
|
||||||
|
: feedsTri() ? "feed\\n"
|
||||||
|
: "-\\n")
|
||||||
+ (nodep()->prettyTypeName() + " " + cvtToHex(nodep())));
|
+ (nodep()->prettyTypeName() + " " + cvtToHex(nodep())));
|
||||||
}
|
}
|
||||||
virtual string dotColor() const override {
|
virtual string dotColor() const override {
|
||||||
return (varp() ? (isTristate() ? "darkblue" : feedsTri() ? "blue" : "lightblue")
|
return (varp() ? (isTristate() ? "darkblue"
|
||||||
: (isTristate() ? "darkgreen" : feedsTri() ? "green" : "lightgreen"));
|
: feedsTri() ? "blue"
|
||||||
|
: "lightblue")
|
||||||
|
: (isTristate() ? "darkgreen"
|
||||||
|
: feedsTri() ? "green"
|
||||||
|
: "lightgreen"));
|
||||||
}
|
}
|
||||||
virtual FileLine* fileline() const override { return nodep()->fileline(); }
|
virtual FileLine* fileline() const override { return nodep()->fileline(); }
|
||||||
void isTristate(bool flag) { m_isTristate = flag; }
|
void isTristate(bool flag) { m_isTristate = flag; }
|
||||||
|
|
|
||||||
|
|
@ -172,8 +172,9 @@ public:
|
||||||
allD = allU = true;
|
allD = allU = true;
|
||||||
if (allU) m_wholeFlags[FLAG_USED] = true;
|
if (allU) m_wholeFlags[FLAG_USED] = true;
|
||||||
if (allD) m_wholeFlags[FLAG_DRIVEN] = true;
|
if (allD) m_wholeFlags[FLAG_DRIVEN] = true;
|
||||||
const char* const what
|
const char* const what = nodep->isParam() ? "parameter"
|
||||||
= nodep->isParam() ? "parameter" : nodep->isGenVar() ? "genvar" : "signal";
|
: nodep->isGenVar() ? "genvar"
|
||||||
|
: "signal";
|
||||||
// Test results
|
// Test results
|
||||||
if (nodep->isIfaceRef()) {
|
if (nodep->isIfaceRef()) {
|
||||||
// For interface top level we don't do any tracking
|
// For interface top level we don't do any tracking
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,10 @@ bool check() {
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int Y = ((tb->OE1) & (!tb->OE2))
|
int Y = ((tb->OE1) & (!tb->OE2)) ? tb->A1
|
||||||
? tb->A1
|
: ((!tb->OE1) & (tb->OE2)) ? tb->A2
|
||||||
: ((!tb->OE1) & (tb->OE2))
|
: ((tb->OE1) & (tb->OE2)) ? (tb->A1 | tb->A2)
|
||||||
? tb->A2
|
: 3; // pullup
|
||||||
: ((tb->OE1) & (tb->OE2)) ? (tb->A1 | tb->A2) : 3; // pullup
|
|
||||||
|
|
||||||
int W = (((tb->OE2) ? (tb->A2 & 0x1) : 0) << tb->A1)
|
int W = (((tb->OE2) ? (tb->A2 & 0x1) : 0) << tb->A1)
|
||||||
| (((tb->OE1) ? (tb->A2 >> 1) & 0x1 : 0) << tb->A2);
|
| (((tb->OE1) ? (tb->A2 >> 1) & 0x1 : 0) << tb->A2);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue