Internals: Cleanup some vlSelf code. No functional change intended.
This commit is contained in:
parent
abc46db3c0
commit
e7adae6f81
|
|
@ -64,10 +64,12 @@ std::ostream& operator<<(std::ostream& os, VNType rhs);
|
||||||
const std::shared_ptr<const string> VSelfPointerText::s_emptyp = std::make_shared<string>("");
|
const std::shared_ptr<const string> VSelfPointerText::s_emptyp = std::make_shared<string>("");
|
||||||
const std::shared_ptr<const string> VSelfPointerText::s_thisp = std::make_shared<string>("this");
|
const std::shared_ptr<const string> VSelfPointerText::s_thisp = std::make_shared<string>("this");
|
||||||
|
|
||||||
|
string VSelfPointerText::replaceThis(bool useSelfForThis, const string& text) {
|
||||||
|
return useSelfForThis ? VString::replaceWord(text, "this", "vlSelf") : text;
|
||||||
|
}
|
||||||
|
|
||||||
string VSelfPointerText::protect(bool useSelfForThis, bool protect) const {
|
string VSelfPointerText::protect(bool useSelfForThis, bool protect) const {
|
||||||
const string& sp
|
return VIdProtect::protectWordsIf(replaceThis(useSelfForThis, asString()), protect);
|
||||||
= useSelfForThis ? VString::replaceWord(asString(), "this", "vlSelf") : asString();
|
|
||||||
return VIdProtect::protectWordsIf(sp, protect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
|
|
|
||||||
|
|
@ -1686,6 +1686,7 @@ public:
|
||||||
bool isVlSym() const { return m_strp->find("vlSymsp") != string::npos; }
|
bool isVlSym() const { return m_strp->find("vlSymsp") != string::npos; }
|
||||||
bool hasThis() const { return m_strp == s_thisp || VString::startsWith(*m_strp, "this"); }
|
bool hasThis() const { return m_strp == s_thisp || VString::startsWith(*m_strp, "this"); }
|
||||||
string protect(bool useSelfForThis, bool protect) const;
|
string protect(bool useSelfForThis, bool protect) const;
|
||||||
|
static string replaceThis(bool useSelfForThis, const string& text);
|
||||||
const std::string& asString() const { return *m_strp; }
|
const std::string& asString() const { return *m_strp; }
|
||||||
bool operator==(const VSelfPointerText& other) const { return *m_strp == *other.m_strp; }
|
bool operator==(const VSelfPointerText& other) const { return *m_strp == *other.m_strp; }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -631,8 +631,10 @@ class AstCFunc final : public AstNode {
|
||||||
bool m_isConstructor : 1; // Is C class constructor
|
bool m_isConstructor : 1; // Is C class constructor
|
||||||
bool m_isDestructor : 1; // Is C class destructor
|
bool m_isDestructor : 1; // Is C class destructor
|
||||||
bool m_isMethod : 1; // Is inside a class definition
|
bool m_isMethod : 1; // Is inside a class definition
|
||||||
bool m_isLoose : 1; // Semantically this is a method, but is implemented as a function
|
bool m_isLoose : 1; // Semantically this is a method, but is implemented as a function with
|
||||||
// with an explicitly passed 'self' pointer as the first argument
|
// an explicitly passed 'self' pointer as the first argument. This can
|
||||||
|
// be slightly faster due to __restrict, and we do not declare in header
|
||||||
|
// so adding/removing loose functions doesn't recompile everything.
|
||||||
bool m_isInline : 1; // Inline function
|
bool m_isInline : 1; // Inline function
|
||||||
bool m_isVirtual : 1; // Virtual function
|
bool m_isVirtual : 1; // Virtual function
|
||||||
bool m_entryPoint : 1; // User may call into this top level function
|
bool m_entryPoint : 1; // User may call into this top level function
|
||||||
|
|
|
||||||
|
|
@ -356,8 +356,7 @@ public:
|
||||||
// code to allow the compiler to generate load store after the
|
// code to allow the compiler to generate load store after the
|
||||||
// if condition (including short-circuit evaluation)
|
// if condition (including short-circuit evaluation)
|
||||||
// speculatively and also reduce the data cache pollution when
|
// speculatively and also reduce the data cache pollution when
|
||||||
// executing in the wrong path to make verilator-generated code
|
// executing in the wrong path to make Verilated code faster.
|
||||||
// run faster.
|
|
||||||
puts("auto& vlSelfRef = std::ref(*vlSelf).get();\n");
|
puts("auto& vlSelfRef = std::ref(*vlSelf).get();\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1064,9 +1063,8 @@ public:
|
||||||
putns(nodep, "vlSymsp->_vm_contextp__->timeprecision()");
|
putns(nodep, "vlSymsp->_vm_contextp__->timeprecision()");
|
||||||
}
|
}
|
||||||
void visit(AstNodeSimpleText* nodep) override {
|
void visit(AstNodeSimpleText* nodep) override {
|
||||||
const string text = m_inUC && m_useSelfForThis
|
const string text
|
||||||
? VString::replaceWord(nodep->text(), "this", "vlSelf")
|
= VSelfPointerText::replaceThis(m_inUC && m_useSelfForThis, nodep->text());
|
||||||
: nodep->text();
|
|
||||||
if (nodep->tracking() || m_trackText) {
|
if (nodep->tracking() || m_trackText) {
|
||||||
puts(text);
|
puts(text);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1342,7 +1340,7 @@ public:
|
||||||
void visit(AstThisRef* nodep) override {
|
void visit(AstThisRef* nodep) override {
|
||||||
putnbs(nodep, nodep->dtypep()->cType("", false, false));
|
putnbs(nodep, nodep->dtypep()->cType("", false, false));
|
||||||
puts("{");
|
puts("{");
|
||||||
puts(m_useSelfForThis ? "vlSelf" : "this");
|
puts(VSelfPointerText::replaceThis(m_useSelfForThis, "this"));
|
||||||
puts("}");
|
puts("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue