Skip to content

Commit b87a33d

Browse files
authored
Merge pull request #5211 from rocallahan/remove-log_str
Remove `log_str()` functions and convert their `log_signal()` users t…
2 parents dd9627e + c7017f7 commit b87a33d

File tree

5 files changed

+23
-34
lines changed

5 files changed

+23
-34
lines changed

kernel/drivertools.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -865,41 +865,41 @@ DriveSpec DriverMap::operator()(DriveSpec spec)
865865
return result;
866866
}
867867

868-
const char *log_signal(DriveChunkWire const &chunk)
868+
std::string log_signal(DriveChunkWire const &chunk)
869869
{
870870
const char *id = log_id(chunk.wire->name);
871871
if (chunk.is_whole())
872872
return id;
873873
if (chunk.width == 1)
874-
return log_str(stringf("%s [%d]", id, chunk.offset));
875-
return log_str(stringf("%s [%d:%d]", id, chunk.offset + chunk.width - 1, chunk.offset));
874+
return stringf("%s [%d]", id, chunk.offset);
875+
return stringf("%s [%d:%d]", id, chunk.offset + chunk.width - 1, chunk.offset);
876876
}
877877

878878

879-
const char *log_signal(DriveChunkPort const &chunk)
879+
std::string log_signal(DriveChunkPort const &chunk)
880880
{
881881
const char *cell_id = log_id(chunk.cell->name);
882882
const char *port_id = log_id(chunk.port);
883883
if (chunk.is_whole())
884-
return log_str(stringf("%s <%s>", cell_id, port_id));
884+
return stringf("%s <%s>", cell_id, port_id);
885885
if (chunk.width == 1)
886-
return log_str(stringf("%s <%s> [%d]", cell_id, port_id, chunk.offset));
887-
return log_str(stringf("%s <%s> [%d:%d]", cell_id, port_id, chunk.offset + chunk.width - 1, chunk.offset));
886+
return stringf("%s <%s> [%d]", cell_id, port_id, chunk.offset);
887+
return stringf("%s <%s> [%d:%d]", cell_id, port_id, chunk.offset + chunk.width - 1, chunk.offset);
888888
}
889889

890-
const char *log_signal(DriveChunkMarker const &chunk)
890+
std::string log_signal(DriveChunkMarker const &chunk)
891891
{
892892
if (chunk.width == 1)
893-
return log_str(stringf("<marker %d> [%d]", chunk.marker, chunk.offset));
894-
return log_str(stringf("<marker %d> [%d:%d]", chunk.marker, chunk.offset + chunk.width - 1, chunk.offset));
893+
return stringf("<marker %d> [%d]", chunk.marker, chunk.offset);
894+
return stringf("<marker %d> [%d:%d]", chunk.marker, chunk.offset + chunk.width - 1, chunk.offset);
895895
}
896896

897-
const char *log_signal(DriveChunk const &chunk)
897+
std::string log_signal(DriveChunk const &chunk)
898898
{
899899
switch (chunk.type())
900900
{
901901
case DriveType::NONE:
902-
return log_str(stringf("<none x%d>", chunk.size()));
902+
return stringf("<none x%d>", chunk.size());
903903
case DriveType::CONSTANT:
904904
return log_const(chunk.constant());
905905
case DriveType::WIRE:
@@ -917,14 +917,14 @@ const char *log_signal(DriveChunk const &chunk)
917917
str += log_signal(single);
918918
}
919919
str += ">";
920-
return log_str(str);
920+
return str;
921921
}
922922
default:
923923
log_abort();
924924
}
925925
}
926926

927-
const char *log_signal(DriveSpec const &spec)
927+
std::string log_signal(DriveSpec const &spec)
928928
{
929929
auto &chunks = spec.chunks();
930930
if (chunks.empty())
@@ -943,7 +943,7 @@ const char *log_signal(DriveSpec const &spec)
943943
}
944944
str += " }";
945945

946-
return log_str(str);
946+
return str;
947947
}
948948

949949
YOSYS_NAMESPACE_END

kernel/drivertools.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef DRIVERTOOLS_H
2121
#define DRIVERTOOLS_H
2222

23+
#include <string>
2324
#include <type_traits>
2425

2526
#include "kernel/rtlil.h"
@@ -39,11 +40,11 @@ struct DriveChunk;
3940

4041
struct DriveSpec;
4142

42-
const char *log_signal(DriveChunkWire const &chunk);
43-
const char *log_signal(DriveChunkPort const &chunk);
44-
const char *log_signal(DriveChunkMarker const &chunk);
45-
const char *log_signal(DriveChunk const &chunk);
46-
const char *log_signal(DriveSpec const &chunk);
43+
std::string log_signal(DriveChunkWire const &chunk);
44+
std::string log_signal(DriveChunkPort const &chunk);
45+
std::string log_signal(DriveChunkMarker const &chunk);
46+
std::string log_signal(DriveChunk const &chunk);
47+
std::string log_signal(DriveSpec const &chunk);
4748

4849
enum class DriveType : unsigned char
4950
{

kernel/functional.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,15 @@ class FunctionalIRConstruction {
638638
}
639639
}
640640
}
641-
void undriven(const char *name) {
641+
void undriven(const std::string& name) {
642642
log_error("The design contains an undriven signal %s. This is not supported by the functional backend. "
643643
"Call setundef with appropriate options to avoid this error.\n", name);
644644
}
645645
// we perform this check separately to give better error messages that include the wire or port name
646646
void check_undriven(DriveSpec const& spec, std::string const& name) {
647647
for(auto const &chunk : spec.chunks())
648648
if(chunk.is_none())
649-
undriven(name.c_str());
649+
undriven(name);
650650
}
651651
public:
652652
void process_queue()

kernel/log.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,6 @@ const char *log_id(const RTLIL::IdString &str)
621621
return log_id_cache.back();
622622
}
623623

624-
const char *log_str(const char *str)
625-
{
626-
log_id_cache.push_back(strdup(str));
627-
return log_id_cache.back();
628-
}
629-
630-
const char *log_str(std::string const &str) {
631-
return log_str(str.c_str());
632-
}
633-
634624
void log_module(RTLIL::Module *module, std::string indent)
635625
{
636626
std::stringstream buf;

kernel/log.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ void log_check_expected();
256256
const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true);
257257
const char *log_const(const RTLIL::Const &value, bool autoint = true);
258258
const char *log_id(const RTLIL::IdString &id);
259-
const char *log_str(const char *str);
260-
const char *log_str(std::string const &str);
261259

262260
template<typename T> static inline const char *log_id(T *obj, const char *nullstr = nullptr) {
263261
if (nullstr && obj == nullptr)

0 commit comments

Comments
 (0)