Hi
I am working on the CHERI fork of LLVM, in order to implement a new calling convention.
As a part of this I need to emit 4 consecutive register clearing instructions, looking like this:
cclear 0, <mask>
cclear 1, <mask>
cclear 2, <mask>
cclear 3, <mask>
The <mask>
represents an 8 bit immediate bitmask.
To produce these instructions, I defined a new target specific SelectionDAG node CLEAR_REGS
.
This node then gets pattern matched to a pseudo instruction PseudoCClear
. I defined the translation in tablegen like this:
def SDT_RISCVClearRegs : SDTypeProfile<0, 0, []>;
def riscv_clear_regs : SDNode<"RISCVISD::CLEAR_REGS", SDT_RISCVClearRegs, [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
let Predicates = [HasCheri, IsCapMode], hasSideEffects = 1 in
def PseudoCClear : Pseudo<(outs), (ins $mask), [(riscv_clear_regs $mask)]>;
I am having trouble assigning the correct type to the $mask
argument of the pseudo instruction.
Without annotating a type the compiler complains about an illegal operand:
RISCVInstrInfoXCheri.td:1125:1: error: Illegal operand for the 'PseudoCClear' instruction!
def PseudoCClear : Pseudo<(outs), (ins $mask), [(riscv_clear_regs $mask)]>;
^
Can anyone help me figure out how to type $mask
?
General feedback on my approach is also welcome.
Thanks,
Elias