Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for S4EMac Extension (PoC for custom register support) #99

Merged
merged 14 commits into from
Aug 22, 2024

Conversation

PhilippvK
Copy link
Member

No description provided.

@PhilippvK PhilippvK self-assigned this Jun 3, 2024
@PhilippvK
Copy link
Member Author

This is an example how the Uses & Defs are added to the tablegen code:

let Predicates = [HasExtXS4EMAC, IsRV32] in {
// class RVInst_MACS_64<dag outs, dag ins> : RVInst<outs, ins, "cv.add.h", "$rd, $rs1, $rs2", [], InstFormatOther> {
class RVInst_MACS_64<dag outs, dag ins> : Instruction, Sched<[]> {
    // General
    let Namespace = "RISCV";
    let Size = 4;
    bits<32> SoftFail = 0;
    bits<32> Inst;

    // Operands
    bits<5> rs1;
    bits<5> rs2;

    // Attributes
    let hasSideEffects = 0;
    let mayLoad = 0;
    let mayStore = 0;
    let isTerminator = 0;
    let Uses = [ACC];
    let Defs = [ACC];

    // Encoding

    let Inst{31-25} = 0b0000001;

    let Inst{24-20} = rs2;

    let Inst{19-15} = rs1;

    let Inst{14-12} = 0b010;

    let Inst{11-7} = 0b00000;

    let Inst{6-0} = 0b0001011;

    dag OutOperandList = outs;
    dag InOperandList = ins;

    // Assembly
    let AsmString = "s4e.macs_64\t$rs1, $rs2";

}
def MACS_64 : RVInst_MACS_64<(outs ), (ins GPR:$rs1, GPR:$rs2)>;

}

@PhilippvK
Copy link
Member Author

The RISCVRegisterInfo.td patch for adding ACC as custom reg is very minimal, since LLVM does not care about the size and type of the reg.

// RISCVRegisterInfo.td - riscv_register_info - INSERTION_START
def ACC : RISCVReg<0, "acc">;
// RISCVRegisterInfo.td - riscv_register_info - INSERTION_END

@PhilippvK PhilippvK marked this pull request as ready for review June 6, 2024 10:18
class RVInst_${name}<dag outs, dag ins> : Instruction, Sched<${sched_str}> {
// General
let Namespace = "RISCV";
let Size = ${xlen // 8};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

floor is surely safe, in that a size other than 32 or 64 seems unlikely, and even DSP-ish 24 is still sized in bytes. But maybe an assert of the assumption would be documentary? (size % 8 == 0)

Copy link
Collaborator

@thomasgoodfellow thomasgoodfellow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible (== I really need to see it through the debugger) and given that it's a PoC the "impurities" (todos, commented-out lines) are surely more acceptable than keeping it unmerged

@PhilippvK
Copy link
Member Author

@thomasgoodfellow I forgot to mention that before we can merge this, https://github.com/DLR-SE/riscv-coredsl-extensions/pull/3/files would need to be merged first…

@PhilippvK PhilippvK merged commit 5775d8d into main Aug 22, 2024
6 of 7 checks passed
@PhilippvK PhilippvK deleted the support-s4e branch November 5, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants