[Assembler] Fix GCC build errors
MODIFY
src/assembler/instruction.h
src/assembler/instruction.h
@@ -52,7 +52,7 @@ struct Field {
struct OpPart {
OpPart(unsigned _value, BitRange _range) : value(_value), range(_range) {}
OpPart(unsigned _value, unsigned _start, unsigned _stop) : value(_value), range({_start, _stop}) {}
- constexpr bool matches(uint32_t instruction) const { return range.decode(instruction) == value; }
+ const bool matches(uint32_t instruction) const { return range.decode(instruction) == value; }
const unsigned value;
const BitRange range;
@@ -250,8 +250,14 @@ public:
const QString& name() const { return m_opcode; }
- static std::shared_ptr<Reg<ISA>> reg() { return std::make_shared<Reg<ISA>>(); }
- static std::shared_ptr<Imm> imm() { return std::make_shared<Imm>(); }
+
+ /**
+ * @brief reg() and imm() return dummy register and immediate expected tokens for a pseudo instruction.
+ * Does not relate to actual regs/imms in an instruction word, but solely used for a pseudoinstruction to
+ * be used within the instruction token checking system.
+ */
+ static std::shared_ptr<Reg<ISA>> reg() { return std::make_shared<Reg<ISA>>(0, 0, 0); }
+ static std::shared_ptr<Imm> imm() { return std::make_shared<Imm>(0, 0, Imm::Repr::Hex, std::vector<ImmPart>{});}
private:
std::function<PseudoExpandRes(const PseudoInstruction& /*this*/, const AssemblerTmp::SourceLine&)> m_expander;

MODIFY
src/assembler/rv32i_assembler.cpp
src/assembler/rv32i_assembler.cpp
@@ -137,125 +137,125 @@ void RV32I_Assembler::addAssemblerFunctor(const QString& opcode, AssemblerFuncto
void RV32I_Assembler::enableExtI(RVInstrVec& instructions, RVPseudoInstrVec& pseudoInstructions) const {
// Pseudo-op functors
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
- new RVPseudoInstr("nop", {}, [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ new RVPseudoInstr("nop", {}, [](const RVPseudoInstr& , const AssemblerTmp::SourceLine&) {
return std::vector<AssemblerTmp::LineTokens>{QString("addi x0 x0 0").split(' ')};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("mv", {RVPseudoInstr::reg(), RVPseudoInstr::reg()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"addi", line.tokens.at(1), line.tokens.at(2), "0"}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("not", {RVPseudoInstr::reg(), RVPseudoInstr::reg()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"xori", line.tokens.at(1), line.tokens.at(2), "-1"}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("neg", {RVPseudoInstr::reg(), RVPseudoInstr::reg()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"sub", line.tokens.at(1), "x0", line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("seqz", {RVPseudoInstr::reg(), RVPseudoInstr::reg()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"sltiu", line.tokens.at(1), line.tokens.at(2), "1"}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("snez", {RVPseudoInstr::reg(), RVPseudoInstr::reg()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"sltu", line.tokens.at(1), "x0", line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("sltz", {RVPseudoInstr::reg(), RVPseudoInstr::reg()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"slt", line.tokens.at(1), line.tokens.at(2), "x0"}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("sgtz", {RVPseudoInstr::reg(), RVPseudoInstr::reg()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"slt", line.tokens.at(1), "x0", line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("beqz", {RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"beq", line.tokens.at(1), "x0", line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("bnez", {RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"bne", line.tokens.at(1), "x0", line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("blez", {RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"bge", "x0", line.tokens.at(1), line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("bgez", {RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"bge", line.tokens.at(1), "x0", line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("bltz", {RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"blt", line.tokens.at(1), "x0", line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("bgtz", {RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"blt", "x0", line.tokens.at(1), line.tokens.at(2)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("bgt", {RVPseudoInstr::reg(), RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"blt", line.tokens.at(2), line.tokens.at(1), line.tokens.at(3)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("ble", {RVPseudoInstr::reg(), RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"bge", line.tokens.at(2), line.tokens.at(1), line.tokens.at(3)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("bgtu", {RVPseudoInstr::reg(), RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"bltu", line.tokens.at(2), line.tokens.at(2), line.tokens.at(3)}};
})));
pseudoInstructions.push_back(std::shared_ptr<RVPseudoInstr>(
new RVPseudoInstr("bleu", {RVPseudoInstr::reg(), RVPseudoInstr::reg(), RVPseudoInstr::imm()},
- [](const RVPseudoInstr& _this, const AssemblerTmp::SourceLine& line) {
+ [](const RVPseudoInstr& , const AssemblerTmp::SourceLine& line) {
return std::vector<AssemblerTmp::LineTokens>{
QStringList{"bgeu", line.tokens.at(2), line.tokens.at(2), line.tokens.at(3)}};
})));

[Assembler] Fix GCC build errors