Skip to content

Commit

Permalink
Merge branch 'mortbopet:master' into assembler
Browse files Browse the repository at this point in the history
  • Loading branch information
SteliosKaragiorgis authored Oct 9, 2023
2 parents fa227f3 + 27fcc58 commit 05c538d
Show file tree
Hide file tree
Showing 7 changed files with 1,181 additions and 422 deletions.
63 changes: 41 additions & 22 deletions src/assembler/rv64i_assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,41 @@ void RV64I_Assembler::enableExtI(const ISAInfoBase *isa,
{RV_I<Reg_T>::Options::shifts64BitVariant,
RV_I<Reg_T>::Options::LI64BitVariant});

instructions.push_back(IType32(Token("addiw"), 0b000));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrI32Type<Reg_T>(Token("addiw"), 0b000, isa)));

instructions.push_back(
IShiftType64(Token("slli"), RVISA::OPIMM, 0b001, 0b000000));
std::shared_ptr<_Instruction>(new RVInstrIShift64Type<Reg_T>(
Token("slli"), RVISA::OPIMM, 0b001, 0b000000, isa)));
instructions.push_back(
IShiftType64(Token("srli"), RVISA::OPIMM, 0b101, 0b000000));
std::shared_ptr<_Instruction>(new RVInstrIShift64Type<Reg_T>(
Token("srli"), RVISA::OPIMM, 0b101, 0b000000, isa)));
instructions.push_back(
IShiftType64(Token("srai"), RVISA::OPIMM, 0b101, 0b010000));

instructions.push_back(RType32(Token("addw"), 0b000, 0b0000000));
instructions.push_back(RType32(Token("subw"), 0b000, 0b0100000));
instructions.push_back(RType32(Token("sllw"), 0b001, 0b0000000));
instructions.push_back(RType32(Token("srlw"), 0b101, 0b0000000));
instructions.push_back(RType32(Token("sraw"), 0b101, 0b0100000));

instructions.push_back(LoadType(Token("lwu"), 0b110));
instructions.push_back(LoadType(Token("ld"), 0b011));
instructions.push_back(SType(Token("sd"), 0b011));

pseudoInstructions.push_back(PseudoLoad(Token("ld")));
pseudoInstructions.push_back(PseudoStore(Token("sd")));
std::shared_ptr<_Instruction>(new RVInstrIShift64Type<Reg_T>(
Token("srai"), RVISA::OPIMM, 0b101, 0b010000, isa)));

instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("addw"), 0b000, 0b0000000, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("subw"), 0b000, 0b0100000, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("sllw"), 0b001, 0b0000000, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("srlw"), 0b101, 0b0000000, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("sraw"), 0b101, 0b0100000, isa)));

instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrLType<Reg_T>(Token("lwu"), 0b110, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrLType<Reg_T>(Token("ld"), 0b011, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrSType<Reg_T>(Token("sd"), 0b011, isa)));

pseudoInstructions.push_back(std::shared_ptr<_PseudoInstruction>(
new RVPseudoInstrLoad<Reg_T>(Token("ld"))));
pseudoInstructions.push_back(std::shared_ptr<_PseudoInstruction>(
new RVPseudoInstrStore<Reg_T>(Token("sd"))));
pseudoInstructions.push_back(
std::shared_ptr<_PseudoInstruction>(new _PseudoInstruction(
Token("negw"), {RegTok, RegTok}, _PseudoExpandFunc(line) {
Expand All @@ -111,11 +125,16 @@ void RV64I_Assembler::enableExtM(const ISAInfoBase *isa,
_PseudoInstrVec &pseudoInstructions) {
RV_M<Reg_T>::enable(isa, instructions, pseudoInstructions);

instructions.push_back(RType32(Token("mulw"), 0b000, 0b0000001));
instructions.push_back(RType32(Token("divw"), 0b100, 0b0000001));
instructions.push_back(RType32(Token("divuw"), 0b101, 0b0000001));
instructions.push_back(RType32(Token("remw"), 0b110, 0b0000001));
instructions.push_back(RType32(Token("remuw"), 0b111, 0b0000001));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("mulw"), 0b000, 0b0000001, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("divw"), 0b100, 0b0000001, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("divuw"), 0b101, 0b0000001, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("remw"), 0b110, 0b0000001, isa)));
instructions.push_back(std::shared_ptr<_Instruction>(
new RVInstrR32Type<Reg_T>(Token("remuw"), 0b111, 0b0000001, isa)));
}

} // namespace Assembler
Expand Down
Loading

0 comments on commit 05c538d

Please sign in to comment.