Commit 25d46864 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Fixed bug when calling a function before it's declaration caused it not to be...

Fixed bug when calling a function before it's declaration caused it not to be passed to the bootimage whitelist
parent b5d23c10
......@@ -66,7 +66,7 @@ namespace C
int inline_decl = 0; // if this is greater than 0 we are inside an inline decl
std::string gen_local(std::string name = ""s) {
std::string id_name = "L("s + std::to_string(last_local_id++) + (name.empty() ? ""s : ", "s + name) + ")"s;
std::string id_name = "L("s + std::to_string(last_global_id++) + (name.empty() ? ""s : ", "s + name) + ")"s;
write_line("MuID "s + id_name + " = " + irbuilder + "->gen_sym(" + irbuilder + ", " + (name.empty() ? "NULL" : "\"@" + name + "\"")+ ");");
return id_name;
}
......@@ -86,15 +86,21 @@ namespace C
id = symbols[name] = globals[name];
} else {
if (global) {
id = symbols[name] = globals[name] = gen_global(name);
id = symbols[name] = globals[name] = gen_global(name);
if (name[0] != '_')
whitelist.push_back(id);
} else {
id = symbols[name] = gen_local(name);
}
}
} else id = symbols[name];
} else {
id = symbols[name];
if (global && globals.count(name) == 0) {
globals[name] = id;
if (name[0] != '_')
whitelist.push_back(id);
}
}
if (name == primordial_name) // We found the primordial function!
primordial_id = id;
......@@ -1204,6 +1210,9 @@ namespace C
}
virtual Any<MuCommInst> visitCommInst(UIRParser::CommInstContext *context) override {
std::string op = context->GLOBAL_NAME()->getText().substr(1, std::string::npos);
// Use the following regex on the MU_CI... definition section in muapi.h to generate this code:
// search #[^ ]* ([A-Z_0-9]*)[^@]*@([a-z0-9.-_]*)
// replace : op == "$2" ? "$1"s
return op == "uvm.new_stack" ? "MU_CI_UVM_NEW_STACK"s
: op == "uvm.kill_stack" ? "MU_CI_UVM_KILL_STACK"s
: op == "uvm.thread_exit" ? "MU_CI_UVM_THREAD_EXIT"s
......@@ -1248,6 +1257,10 @@ namespace C
: op == "uvm.meta.enable_watchpoint" ? "MU_CI_UVM_META_ENABLE_WATCHPOINT"s
: op == "uvm.meta.disable_watchpoint" ? "MU_CI_UVM_META_DISABLE_WATCHPOINT"s
: op == "uvm.meta.set_trap_handler" ? "MU_CI_UVM_META_SET_TRAP_HANDLER"s
: op == "uvm.meta.constant_by_id" ? "MU_CI_UVM_META_CONSTANT_BY_ID"s
: op == "uvm.meta.global_by_id" ? "MU_CI_UVM_META_GLOBAL_BY_ID"s
: op == "uvm.meta.func_by_id" ? "MU_CI_UVM_META_FUNC_BY_ID"s
: op == "uvm.meta.expfunc_by_id" ? "MU_CI_UVM_META_EXPFUNC_BY_ID"s
: op == "uvm.irbuilder.new_ir_builder" ? "MU_CI_UVM_IRBUILDER_NEW_IR_BUILDER"s
: op == "uvm.irbuilder.load" ? "MU_CI_UVM_IRBUILDER_LOAD"s
: op == "uvm.irbuilder.abort" ? "MU_CI_UVM_IRBUILDER_ABORT"s
......
......@@ -54,7 +54,14 @@ namespace Runtime
whitelist.push_back(id);
}
}
} else id = symbols[name];
} else {
id = symbols[name];
if (global && globals.count(name) == 0) {
globals[name] = id;
if (name[0] != '_')
whitelist.push_back(id);
}
}
if (name == primordial_name)
primordial_id = id;
......@@ -1219,6 +1226,9 @@ namespace Runtime
}
virtual Any<MuCommInst> visitCommInst(UIRParser::CommInstContext *context) override {
std::string op = context->GLOBAL_NAME()->getText().substr(1, std::string::npos);
// Use the following regex on the MU_CI... definition section in muapi.h to generate this code:
// search #[^ ]* ([A-Z_0-9]*)[^@]*@([a-z0-9.-_]*)
// replace : op == "$2" ? $1
return op == "uvm.new_stack" ? MU_CI_UVM_NEW_STACK
: op == "uvm.kill_stack" ? MU_CI_UVM_KILL_STACK
: op == "uvm.thread_exit" ? MU_CI_UVM_THREAD_EXIT
......@@ -1263,6 +1273,10 @@ namespace Runtime
: op == "uvm.meta.enable_watchpoint" ? MU_CI_UVM_META_ENABLE_WATCHPOINT
: op == "uvm.meta.disable_watchpoint" ? MU_CI_UVM_META_DISABLE_WATCHPOINT
: op == "uvm.meta.set_trap_handler" ? MU_CI_UVM_META_SET_TRAP_HANDLER
: op == "uvm.meta.constant_by_id" ? MU_CI_UVM_META_CONSTANT_BY_ID
: op == "uvm.meta.global_by_id" ? MU_CI_UVM_META_GLOBAL_BY_ID
: op == "uvm.meta.func_by_id" ? MU_CI_UVM_META_FUNC_BY_ID
: op == "uvm.meta.expfunc_by_id" ? MU_CI_UVM_META_EXPFUNC_BY_ID
: op == "uvm.irbuilder.new_ir_builder" ? MU_CI_UVM_IRBUILDER_NEW_IR_BUILDER
: op == "uvm.irbuilder.load" ? MU_CI_UVM_IRBUILDER_LOAD
: op == "uvm.irbuilder.abort" ? MU_CI_UVM_IRBUILDER_ABORT
......
......@@ -125,8 +125,8 @@ int main(int argc, char* argv[]) {
<< "#include \"muapi.h\"" << std::endl
<< "#include \"mu-fastimpl.h\"" << std::endl
<< std::endl
<< "#define G(id, ...) global_ ## id" << std::endl
<< "#define L(id, ...) local_ ## id" << std::endl
<< "#define G(id, ...) muid_ ## id" << std::endl
<< "#define L(id, ...) muid_ ## id" << std::endl
<< std::endl;
// Function header
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment