Skip to content

Commit 701cc69

Browse files
committed
remove log
1 parent acd03b7 commit 701cc69

File tree

4 files changed

+14
-97
lines changed

4 files changed

+14
-97
lines changed

src/machine/bitfield.h

-5
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,12 @@ struct SplitBitField {
4040
}
4141
[[nodiscard]] typename decltype(fields)::const_iterator end() const { return fields.cend(); }
4242
[[nodiscard]] uint32_t decode(uint32_t ins) const {
43-
printf(" decode\n");
4443
uint32_t ret = 0;
4544
size_t offset = 0;
4645
for (BitField field : *this) {
4746
ret |= field.decode(ins) << offset;
4847
offset += field.count;
4948
}
50-
printf(" - ret_unshift: %x\n", ret);
51-
printf(" - val_shift: %x\n", value_shift);
52-
printf(" - str_shift: %x\n", str_shift);
53-
printf(" - res: %x\n", ret << value_shift);
5449
return ret << value_shift;
5550
}
5651
[[nodiscard]] uint32_t decode_str(uint32_t ins) const {

src/machine/instruction.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,7 @@ struct ArgumentDesc {
4949
[[nodiscard]] constexpr bool is_value_in_field_range(RegisterValue val) const {
5050
if (min < 0) {
5151
int32_t val_ = val.as_i32();
52-
printf("---------<<< filed_value: %d ", val_);
5352
val_ >>= arg.str_shift;
54-
printf("val_: %d ", val_);
55-
printf("str_shift: %d ", arg.str_shift);
56-
printf("val_shift: %d ", arg.value_shift);
57-
printf("min: %d ", min);
58-
printf("max: %d\n", max);
5953
return val_ <= max && val_ >= min;
6054
} else {
6155
uint64_t val_ = val.as_u64() >> arg.str_shift;
@@ -800,9 +794,7 @@ QString Instruction::to_str(Address inst_addr) const {
800794
continue;
801795
}
802796

803-
printf("this->dt: %x\n", this->dt);
804797
auto field = (int32_t)arg_desc->arg.decode_str(this->dt);
805-
printf("field: : %x\n", field);
806798
if (arg_desc->min < 0) {
807799
field = extend(field, [&]() {
808800
int sum = (int)arg_desc->arg.str_shift;
@@ -825,7 +817,6 @@ QString Instruction::to_str(Address inst_addr) const {
825817
case 'a': {
826818
field += (int32_t)inst_addr.get_raw();
827819
QString a = str::asHex(field);
828-
printf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: field: %x, asHex: %s\n", field, qPrintable(a));
829820
res.append(str::asHex(field));
830821
break;
831822
}
@@ -1330,7 +1321,6 @@ uint32_t Instruction::parse_field(
13301321
if (effective_mod != Modifier::NONE) {
13311322
val = modify_pseudoinst_imm(effective_mod, val);
13321323
} else if (!adesc->is_value_in_field_range(val)) {
1333-
printf("field: %s, val: %d, val_i: %d\n", qPrintable(field_token), val, (int64_t)val);
13341324
throw ParseError("argument range exceed");
13351325
}
13361326

src/machine/instruction.test.gendata.cpp

+14-70
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ random_arg_code_mask(const ArgumentDesc *arg_desc, const InstructionMap *im, int
1212
= QRandomGenerator::global()->bounded(int32_t(arg_desc->min), int32_t(arg_desc->max));
1313

1414
// set fields from value
15-
printf("\n ::random_arg_code_mask\n");
1615
uint32_t code_mask = arg_desc->arg.encode(value);
1716

1817
switch (arg_desc->name) {
@@ -24,8 +23,6 @@ random_arg_code_mask(const ArgumentDesc *arg_desc, const InstructionMap *im, int
2423
}
2524
}
2625

27-
printf(" gen: [%x > %x < %x]\n", arg_desc->min, value, arg_desc->max);
28-
2926
// set to zero if needed
3027
if (zero_mask_tb.count(im->name)) { code_mask &= zero_mask_tb[im->name].zero_mask; }
3128

@@ -131,8 +128,6 @@ GeneratedInst random_inst_from_im(const InstructionMap *im, const InstructionMap
131128
Instruction::Type t = im->type;
132129
if (im_source != nullptr) { t = im_source->type; }
133130

134-
printf(
135-
" ::random_inst_from_im code code: %10x, code-masked: %10x\n", code, code & im->mask);
136131
code &= im->mask;
137132

138133
QString next_delim = " ";
@@ -170,17 +165,12 @@ GeneratedInst random_inst_from_im(const InstructionMap *im, const InstructionMap
170165
}
171166
case 'E': {
172167
QString csr_name = CSR::REGISTERS[CSR::REGISTER_MAP.at(CSR::Address(field))].name;
173-
DEBUG &&printf(
174-
"csr code_mask: 0x%x, name: %s\n", code_mask >> 20, qPrintable(csr_name));
175168
string_data += csr_name;
176169
break;
177170
};
178171
}
179172

180-
DEBUG &&printf("code_mask bef: 0x%x, name: %s\n", code, qPrintable(string_data));
181173
code |= code_mask;
182-
printf("\n result code: [%x] mask: [%x] field: [%d]\n", code, code_mask, field);
183-
DEBUG &&printf("code_mask aft: 0x%x, name: %s\n", code, qPrintable(string_data));
184174
}
185175
}
186176
return GeneratedInst { code, string_data, im, im_source };
@@ -263,65 +253,19 @@ void WalkInstructionMap(
263253
int main() {
264254
fill_argdesbycode();
265255
instruction_from_string_build_base();
266-
267-
// char *s = "0xFFF\0";
268-
// long long res = strtoll(s, nullptr, 10);
269-
// printf("res: %lld", res);
270-
// return 0;
271-
272-
struct {
273-
uint32_t code;
274-
QString string_data;
275-
} a[] {
276-
{ 0x34b358f3, "csrrwi x17, mtval2, 0x6" },
277-
};
278-
for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
279-
uint32_t code = a[i].code;
280-
QString string_data = a[i].string_data;
281-
282-
QString parsed_string_data = Instruction(code).to_str();
283-
284-
// DEBUG LOG
285-
printf(
286-
"test to_str: 0x%x, %s => { %s }\n", code, qPrintable(string_data),
287-
qPrintable(parsed_string_data));
288-
289-
try {
290-
uint32_t parsed_code;
291-
Instruction::code_from_string(
292-
&parsed_code, parsed_string_data.length(), string_data, Address(0x0));
293-
printf(
294-
"test from_string: 0x%x, %s => { 0x%x }\n", code, qPrintable(string_data),
295-
parsed_code);
296-
} catch (const Instruction::ParseError &e) {
297-
printf("test from_string: failed, reason: %s\n", qPrintable(e.message));
298-
}
299-
printf("\n");
300-
/* data */
301-
};
302-
printf("----------------------------------------------------------------------------\n");
303-
304-
QFile outfile("instruction.test.data.def");
305-
if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
306-
QTextStream out(&outfile);
307-
WalkInstructionMap([](const InstructionMap *im, const InstructionMap *im_source) {
308-
printf("\n\n");
309-
310-
printf("inst: [%s] \n\n", im->name);
311-
for (int i = 0; i < 30; i++) {
312-
printf(" - inst - test-[%d] \n", i);
313-
auto generated = random_inst_from_im(im, im_source);
314-
if (generated.im != nullptr) {
315-
printf(" code: [%10x] ", generated.code);
316-
printf(" str: [%30s] ", qPrintable(generated.string_data));
317-
printf("\n");
318-
if (!generated.check()) { throw Instruction::ParseError(""); }
319-
}
256+
WalkInstructionMap([](const InstructionMap *im, const InstructionMap *im_source) {
257+
printf("\n\n");
258+
259+
printf("inst: [%s] \n\n", im->name);
260+
for (int i = 0; i < 100; i++) {
261+
printf(" - inst - test-[%d] \n", i);
262+
auto generated = random_inst_from_im(im, im_source);
263+
if (generated.im != nullptr) {
264+
printf(" code: [%10x] ", generated.code);
265+
printf(" str: [%30s] ", qPrintable(generated.string_data));
266+
printf("\n");
267+
if (!generated.check()) { throw Instruction::ParseError(""); }
320268
}
321-
});
322-
outfile.close();
323-
} else {
324-
printf("open output file failed\n");
325-
exit(1);
326-
}
269+
}
270+
});
327271
}

src/machine/instruction.test.gendata.h

-12
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,4 @@ static const QMap<QString, ADDITIONAL_TB> zero_mask_tb = {
9595
{ "csrrs", { ~MASK_I_RS1.mask() } }
9696
};
9797

98-
class MockInstruction : public Instruction {
99-
Type _type;
100-
101-
public:
102-
MockInstruction(uint32_t inst, Type type) {
103-
this->dt = inst;
104-
this->_type = type;
105-
};
106-
107-
enum Type type() const { return this->_type; }
108-
};
109-
11098
#endif

0 commit comments

Comments
 (0)