Skip to content

Commit d18cad9

Browse files
jdupakppisa
authored andcommitted
Project: force clang format
1 parent e4470d5 commit d18cad9

File tree

113 files changed

+1730
-2418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1730
-2418
lines changed

.clang-format

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
---
2-
Language: Cpp
32
# BasedOnStyle: WebKit
43
AccessModifierOffset: -4
54
AlignAfterOpenBracket: AlwaysBreak
6-
AlignConsecutiveMacros: false
5+
AlignConsecutiveMacros: true
76
AlignConsecutiveAssignments: false
87
AlignConsecutiveDeclarations: false
98
AlignEscapedNewlines: Right
@@ -120,4 +119,4 @@ StatementMacros:
120119
- QT_REQUIRE_VERSION
121120
TabWidth: 4
122121
UseCRLF: false
123-
UseTab: Never
122+
UseTab: Never

src/assembler/simpleasm.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class SimpleAsm : public QObject {
4848
~SimpleAsm() override;
4949

5050
public:
51-
static uint64_t
52-
string_to_uint64(const QString &str, int base, int *chars_taken = nullptr);
51+
static uint64_t string_to_uint64(const QString &str, int base, int *chars_taken = nullptr);
5352
void clear();
5453
void setup(
5554
machine::FrontendMemory *mem,
@@ -61,8 +60,7 @@ class SimpleAsm : public QObject {
6160
const QString &filename = "",
6261
int line_number = 0,
6362
QString *error_ptr = nullptr);
64-
virtual bool
65-
process_file(const QString &filename, QString *error_ptr = nullptr);
63+
virtual bool process_file(const QString &filename, QString *error_ptr = nullptr);
6664
bool finish(QString *error_ptr = nullptr);
6765

6866
protected:

src/cli/chariohandler.cpp

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,20 @@
11
#include "chariohandler.h"
22

3-
CharIOHandler::CharIOHandler(QIODevice *iodev, QObject *parent)
4-
: QIODevice(parent)
5-
, fd_list() {
3+
CharIOHandler::CharIOHandler(QIODevice *iodev, QObject *parent) : QIODevice(parent), fd_list() {
64
this->iodev = iodev;
7-
if (!iodev->parent()) {
8-
iodev->setParent(this);
9-
}
5+
if (!iodev->parent()) { iodev->setParent(this); }
106
fd_specific = false;
11-
if (iodev->isOpen()) {
12-
Super::open(iodev->openMode());
13-
}
7+
if (iodev->isOpen()) { Super::open(iodev->openMode()); }
148
connect(iodev, &Super::aboutToClose, this, &CharIOHandler::aboutToClose);
159
connect(iodev, &Super::bytesWritten, this, &CharIOHandler::bytesWritten);
16-
connect(
17-
iodev, &Super::channelBytesWritten, this,
18-
&CharIOHandler::channelBytesWritten);
19-
connect(
20-
iodev, &Super::channelReadyRead, this,
21-
&CharIOHandler::channelReadyRead);
22-
connect(
23-
iodev, &Super::readChannelFinished, this,
24-
&CharIOHandler::readChannelFinished);
10+
connect(iodev, &Super::channelBytesWritten, this, &CharIOHandler::channelBytesWritten);
11+
connect(iodev, &Super::channelReadyRead, this, &CharIOHandler::channelReadyRead);
12+
connect(iodev, &Super::readChannelFinished, this, &CharIOHandler::readChannelFinished);
2513
connect(iodev, &Super::readyRead, this, &CharIOHandler::readyRead);
2614
}
2715

2816
CharIOHandler::~CharIOHandler() {
29-
if (iodev->parent() == this)
30-
delete iodev;
17+
if (iodev->parent() == this) { delete iodev; }
3118
}
3219

3320
void CharIOHandler::writeByte(unsigned int data) {
@@ -36,8 +23,7 @@ void CharIOHandler::writeByte(unsigned int data) {
3623
}
3724

3825
void CharIOHandler::writeByte(int fd, unsigned int data) {
39-
if (!fd_specific || fd_list.contains(fd))
40-
writeByte(data);
26+
if (!fd_specific || fd_list.contains(fd)) { writeByte(data); }
4127
}
4228

4329
void CharIOHandler::readBytePoll(int fd, unsigned int &data, bool &available) {
@@ -67,9 +53,7 @@ bool CharIOHandler::isSequential() const {
6753
}
6854

6955
bool CharIOHandler::open(OpenMode mode) {
70-
if (!iodev->open(mode)) {
71-
return false;
72-
}
56+
if (!iodev->open(mode)) { return false; }
7357
Super::open(mode);
7458
return true;
7559
}

src/cli/main.cpp

Lines changed: 66 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "common/logging.h"
44
#include "common/logging_format_colors.h"
55
#include "machine/machineconfig.h"
6-
#include "os_emulation/ossyscall.h"
76
#include "msgreport.h"
7+
#include "os_emulation/ossyscall.h"
88
#include "reporter.h"
99
#include "tracer.h"
1010

@@ -34,23 +34,29 @@ void create_parser(QCommandLineParser &p) {
3434
p.addOption({ "no-delay-slot", "Disable jump delay slot." });
3535
p.addOption(
3636
{ "hazard-unit", "Specify hazard unit implementation [none|stall|forward].", "HUKIND" });
37-
p.addOption({ { "trace-fetch", "tr-fetch" },
38-
"Trace fetched instruction (for both pipelined and not core)." });
39-
p.addOption({ { "trace-decode", "tr-decode" },
40-
"Trace instruction in decode stage. (only for pipelined core)" });
41-
p.addOption({ { "trace-execute", "tr-execute" },
42-
"Trace instruction in execute stage. (only for pipelined core)" });
43-
p.addOption({ { "trace-memory", "tr-memory" },
44-
"Trace instruction in memory stage. (only for pipelined core)" });
45-
p.addOption({ { "trace-writeback", "tr-writeback" },
46-
"Trace instruction in write back stage. (only for pipelined core)" });
37+
p.addOption(
38+
{ { "trace-fetch", "tr-fetch" },
39+
"Trace fetched instruction (for both pipelined and not core)." });
40+
p.addOption(
41+
{ { "trace-decode", "tr-decode" },
42+
"Trace instruction in decode stage. (only for pipelined core)" });
43+
p.addOption(
44+
{ { "trace-execute", "tr-execute" },
45+
"Trace instruction in execute stage. (only for pipelined core)" });
46+
p.addOption(
47+
{ { "trace-memory", "tr-memory" },
48+
"Trace instruction in memory stage. (only for pipelined core)" });
49+
p.addOption(
50+
{ { "trace-writeback", "tr-writeback" },
51+
"Trace instruction in write back stage. (only for pipelined core)" });
4752
p.addOption({ { "trace-pc", "tr-pc" }, "Print program counter register changes." });
4853
p.addOption({ { "trace-wrmem", "tr-wr" }, "Trace writes into memory." });
4954
p.addOption({ { "trace-rdmem", "tr-rd" }, "Trace reads from memory." });
50-
p.addOption({ { "trace-gp", "tr-gp" },
51-
"Print general purpose register changes. You can use * for "
52-
"all registers.",
53-
"REG" });
55+
p.addOption(
56+
{ { "trace-gp", "tr-gp" },
57+
"Print general purpose register changes. You can use * for "
58+
"all registers.",
59+
"REG" });
5460
p.addOption({ "dump-to-json", "Configure reportor dump to json file.", "FNAME" });
5561
p.addOption({ "only-dump", "Do not start the processor." });
5662
p.addOption({ "disable-console-dump", "Configure reporter not to dump to console." });
@@ -61,34 +67,41 @@ void create_parser(QCommandLineParser &p) {
6167
p.addOption({ "dump-symbol-table", "Dump the symbol table." });
6268
p.addOption({ "load-range", "Load memory range.", "START,FNAME" });
6369
p.addOption({ "expect-fail", "Expect that program causes CPU trap and fail if it doesn't." });
64-
p.addOption({ "fail-match",
65-
"Program should exit with exactly this CPU TRAP. Possible values are "
66-
"I(unsupported Instruction), A(Unsupported ALU operation), "
67-
"O(Overflow/underflow) and J(Unaligned Jump). You can freely combine "
68-
"them. Using this implies expect-fail option.",
69-
"TRAP" });
70-
p.addOption({ "d-cache",
71-
"Data cache. Format policy,sets,words_in_blocks,associativity where "
72-
"policy is random/lru/lfu",
73-
"DCACHE" });
74-
p.addOption({ "i-cache",
75-
"Instruction cache. Format policy,sets,words_in_blocks,associativity "
76-
"where policy is random/lru/lfu",
77-
"ICACHE" });
78-
p.addOption({ "l2-cache",
79-
"L2 cache. Format policy,sets,words_in_blocks,associativity where "
80-
"policy is random/lru/lfu",
81-
"L2CACHE" });
70+
p.addOption(
71+
{ "fail-match",
72+
"Program should exit with exactly this CPU TRAP. Possible values are "
73+
"I(unsupported Instruction), A(Unsupported ALU operation), "
74+
"O(Overflow/underflow) and J(Unaligned Jump). You can freely combine "
75+
"them. Using this implies expect-fail option.",
76+
"TRAP" });
77+
p.addOption(
78+
{ "d-cache",
79+
"Data cache. Format policy,sets,words_in_blocks,associativity where "
80+
"policy is random/lru/lfu",
81+
"DCACHE" });
82+
p.addOption(
83+
{ "i-cache",
84+
"Instruction cache. Format policy,sets,words_in_blocks,associativity "
85+
"where policy is random/lru/lfu",
86+
"ICACHE" });
87+
p.addOption(
88+
{ "l2-cache",
89+
"L2 cache. Format policy,sets,words_in_blocks,associativity where "
90+
"policy is random/lru/lfu",
91+
"L2CACHE" });
8292
p.addOption({ "read-time", "Memory read access time (cycles).", "RTIME" });
8393
p.addOption({ "write-time", "Memory read access time (cycles).", "WTIME" });
8494
p.addOption({ "burst-time", "Memory read access time (cycles).", "BTIME" });
8595
p.addOption({ { "serial-in", "serin" }, "File connected to the serial port input.", "FNAME" });
8696
p.addOption(
8797
{ { "serial-out", "serout" }, "File connected to the serial port output.", "FNAME" });
8898
p.addOption({ { "os-emulation", "osemu" }, "Operating system emulation." });
89-
p.addOption({ { "std-out", "stdout" }, "File connected to the syscall standard output.", "FNAME" });
90-
p.addOption({ { "os-fs-root", "osfsroot" }, "Emulated system root/prefix for opened files", "DIR" });
91-
p.addOption({ { "isa-variant", "isavariant" }, "Instruction set to emulate (default RV32IMA)", "STR" });
99+
p.addOption(
100+
{ { "std-out", "stdout" }, "File connected to the syscall standard output.", "FNAME" });
101+
p.addOption(
102+
{ { "os-fs-root", "osfsroot" }, "Emulated system root/prefix for opened files", "DIR" });
103+
p.addOption(
104+
{ { "isa-variant", "isavariant" }, "Instruction set to emulate (default RV32IMA)", "STR" });
92105
p.addOption({ "cycle-limit", "Limit execution to specified maximum clock cycles", "NUMBER" });
93106
}
94107

@@ -205,19 +218,18 @@ void configure_machine(QCommandLineParser &parser, MachineConfig &config) {
205218
int siz = parser.values("os-fs-root").size();
206219
if (siz >= 1) {
207220
QString osemu_fs_root = parser.values("os-fs-root").at(siz - 1);
208-
if (osemu_fs_root.length() > 0)
209-
config.set_osemu_fs_root(osemu_fs_root);
221+
if (osemu_fs_root.length() > 0) { config.set_osemu_fs_root(osemu_fs_root); }
210222
}
211223
siz = parser.values("isa-variant").size();
212224
for (int i = 0; i < siz; i++) {
213225
int pos = 0;
214226
bool first = true;
215227
bool subtract = false;
216228
QString isa_str = parser.values("isa-variant").at(i).toUpper();
217-
if (isa_str.startsWith ("RV32")) {
229+
if (isa_str.startsWith("RV32")) {
218230
config.set_simulated_xlen(machine::Xlen::_32);
219231
pos = 4;
220-
} else if (isa_str.startsWith ("RV64")) {
232+
} else if (isa_str.startsWith("RV64")) {
221233
config.set_simulated_xlen(machine::Xlen::_64);
222234
pos = 4;
223235
}
@@ -231,10 +243,10 @@ void configure_machine(QCommandLineParser &parser, MachineConfig &config) {
231243
continue;
232244
}
233245
auto flag = machine::ConfigIsaWord::byChar(ch);
234-
if (flag.isEmpty())
235-
continue;
246+
if (flag.isEmpty()) continue;
236247
if (first)
237-
config.modify_isa_word(~machine::ConfigIsaWord::empty(), machine::ConfigIsaWord::empty());
248+
config.modify_isa_word(
249+
~machine::ConfigIsaWord::empty(), machine::ConfigIsaWord::empty());
238250
if (subtract)
239251
config.modify_isa_word(flag, machine::ConfigIsaWord::empty());
240252
else
@@ -256,7 +268,7 @@ void configure_tracer(QCommandLineParser &p, Tracer &tr) {
256268
if (p.isSet("trace-gp")) { tr.trace_regs_gp = true; }
257269

258270
QStringList gps = p.values("trace-gp");
259-
for (const auto & gp : gps) {
271+
for (const auto &gp : gps) {
260272
if (gp == "*") {
261273
tr.regs_to_trace.fill(true);
262274
} else {
@@ -265,8 +277,7 @@ void configure_tracer(QCommandLineParser &p, Tracer &tr) {
265277
if (res && num <= machine::REGISTER_COUNT) {
266278
tr.regs_to_trace.at(num) = true;
267279
} else {
268-
fprintf(
269-
stderr, "Unknown register number given for trace-gp: %s\n", qPrintable(gp));
280+
fprintf(stderr, "Unknown register number given for trace-gp: %s\n", qPrintable(gp));
270281
exit(EXIT_FAILURE);
271282
}
272283
}
@@ -280,8 +291,7 @@ void configure_tracer(QCommandLineParser &p, Tracer &tr) {
280291
bool ok;
281292
tr.cycle_limit = clim.at(clim.size() - 1).toLong(&ok);
282293
if (!ok) {
283-
fprintf(
284-
stderr, "Cycle limit parse error\n");
294+
fprintf(stderr, "Cycle limit parse error\n");
285295
exit(EXIT_FAILURE);
286296
}
287297
}
@@ -303,7 +313,7 @@ void configure_reporter(QCommandLineParser &p, Reporter &r, const SymbolTable *s
303313
if (p.isSet("dump-symbol-table")) { r.enable_symbol_table_reporting(); }
304314

305315
QStringList fail = p.values("fail-match");
306-
for (const auto & i : fail) {
316+
for (const auto &i : fail) {
307317
for (int y = 0; y < i.length(); y++) {
308318
enum Reporter::FailReason reason;
309319
switch (tolower(i.toStdString()[y])) {
@@ -420,17 +430,18 @@ void configure_osemu(QCommandLineParser &p, MachineConfig &config, Machine *mach
420430
exit(EXIT_FAILURE);
421431
}
422432
}
423-
const static machine::ExceptionCause ecall_variats[] = {machine::EXCAUSE_ECALL_ANY,
424-
machine::EXCAUSE_ECALL_M, machine::EXCAUSE_ECALL_S, machine::EXCAUSE_ECALL_U};
433+
const static machine::ExceptionCause ecall_variats[]
434+
= { machine::EXCAUSE_ECALL_ANY, machine::EXCAUSE_ECALL_M, machine::EXCAUSE_ECALL_S,
435+
machine::EXCAUSE_ECALL_U };
425436

426437
if (config.osemu_enable()) {
427438
auto *osemu_handler = new osemu::OsSyscallExceptionHandler(
428439
config.osemu_known_syscall_stop(), config.osemu_unknown_syscall_stop(),
429440
config.osemu_fs_root());
430441
if (std_out) {
431442
machine::Machine::connect(
432-
osemu_handler, &osemu::OsSyscallExceptionHandler::char_written,
433-
std_out, QOverload<int, unsigned>::of(&CharIOHandler::writeByte));
443+
osemu_handler, &osemu::OsSyscallExceptionHandler::char_written, std_out,
444+
QOverload<int, unsigned>::of(&CharIOHandler::writeByte));
434445
}
435446
/*connect(
436447
osemu_handler, &osemu::OsSyscallExceptionHandler::rx_byte_pool, terminal,
@@ -475,9 +486,7 @@ void load_ranges(Machine &machine, const QStringList &ranges) {
475486
Address addr = start;
476487
for (std::string line; getline(in, line);) {
477488
size_t end_pos = line.find_last_not_of(" \t\n");
478-
if (std::string::npos == end_pos) {
479-
continue;
480-
}
489+
if (std::string::npos == end_pos) { continue; }
481490

482491
size_t start_pos = line.find_first_not_of(" \t\n");
483492
line = line.substr(0, end_pos + 1);
@@ -507,9 +516,7 @@ bool assemble(Machine &machine, MsgReport &msgrep, const QString &filename) {
507516

508517
assembler.setup(mem, &symbol_table_db, 0x00000200_addr, machine.core()->get_xlen());
509518

510-
if (!assembler.process_file(filename)) {
511-
return false;
512-
}
519+
if (!assembler.process_file(filename)) { return false; }
513520

514521
return assembler.finish();
515522
}

src/cli/reporter.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,16 @@ void Reporter::report() {
114114
for (const auto &name : machine->symbol_table()->names()) {
115115
SymbolValue sym_val;
116116
machine->symbol_table()->name_to_value(sym_val, name);
117-
QString value = QString::asprintf(machine->core()->get_xlen() == Xlen::_32 ? "0x%08" PRIx64 : "0x%016" PRIx64, sym_val);
118-
if (dump_format & DumpFormat::JSON) {
119-
symtab_json[name] = value;
120-
}
117+
QString value = QString::asprintf(
118+
machine->core()->get_xlen() == Xlen::_32 ? "0x%08" PRIx64 : "0x%016" PRIx64,
119+
sym_val);
120+
if (dump_format & DumpFormat::JSON) { symtab_json[name] = value; }
121121
if (dump_format & DumpFormat::CONSOLE) {
122122
printf("SYM[%s]: %s\n", qPrintable(name), qPrintable(value));
123123
}
124124
}
125125

126-
if (dump_format & DumpFormat::JSON) {
127-
dump_data_json["symbols"] = symtab_json;
128-
}
126+
if (dump_format & DumpFormat::JSON) { dump_data_json["symbols"] = symtab_json; }
129127
}
130128

131129
if (dump_format & DumpFormat::JSON) {

src/cli/tracer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ void Tracer::step_output() {
4040
printf("GP %zu: %" PRIx64 "\n", size_t(wb.num_rd), wb.value.as_u64());
4141
}
4242
if (trace_rdmem && mem_wb.memtoreg) {
43-
printf("MEM[%" PRIx64 "]: RD %" PRIx64 "\n", mem_wb.mem_addr.get_raw(),
44-
mem_wb.towrite_val.as_u64());
43+
printf(
44+
"MEM[%" PRIx64 "]: RD %" PRIx64 "\n", mem_wb.mem_addr.get_raw(),
45+
mem_wb.towrite_val.as_u64());
4546
}
4647
if (trace_wrmem && mem.memwrite) {
47-
printf("MEM[%" PRIx64 "]: WR %" PRIx64 "\n", mem_wb.mem_addr.get_raw(),
48-
mem.mem_write_val.as_u64());
48+
printf(
49+
"MEM[%" PRIx64 "]: WR %" PRIx64 "\n", mem_wb.mem_addr.get_raw(),
50+
mem.mem_write_val.as_u64());
4951
}
5052
if ((cycle_limit != 0) && (core_state.cycle_count >= cycle_limit)) {
5153
emit cycle_limit_reached();

src/cli/tracer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private slots:
2828
public:
2929
std::array<bool, machine::REGISTER_COUNT> regs_to_trace = {};
3030
bool trace_fetch = false, trace_decode = false, trace_execute = false, trace_memory = false,
31-
trace_writeback = false, trace_pc = false, trace_wrmem = false, trace_rdmem = false,
31+
trace_writeback = false, trace_pc = false, trace_wrmem = false, trace_rdmem = false,
3232
trace_regs_gp = false;
3333
quint64 cycle_limit;
3434
};

0 commit comments

Comments
 (0)