Add RISC-V encodings for copy instructions.
This commit is contained in:
@@ -77,6 +77,10 @@ ebb0(v9999: i32):
|
|||||||
[-,%x7] v140 = iconst.i32 0x12345000 ; bin: 123453b7
|
[-,%x7] v140 = iconst.i32 0x12345000 ; bin: 123453b7
|
||||||
[-,%x16] v141 = iconst.i32 0xffffffff_fedcb000 ; bin: fedcb837
|
[-,%x16] v141 = iconst.i32 0xffffffff_fedcb000 ; bin: fedcb837
|
||||||
|
|
||||||
|
; Copies alias to iadd_imm.
|
||||||
|
[-,%x7] v150 = copy v1 ; bin: 00050393
|
||||||
|
[-,%x16] v151 = copy v2 ; bin: 000a8813
|
||||||
|
|
||||||
; Control Transfer Instructions
|
; Control Transfer Instructions
|
||||||
|
|
||||||
; jal %x1, fn0
|
; jal %x1, fn0
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from base.immediates import intcc
|
|||||||
from .defs import RV32, RV64
|
from .defs import RV32, RV64
|
||||||
from .recipes import OPIMM, OPIMM32, OP, OP32, LUI, BRANCH, JALR, JAL
|
from .recipes import OPIMM, OPIMM32, OP, OP32, LUI, BRANCH, JALR, JAL
|
||||||
from .recipes import LOAD, STORE
|
from .recipes import LOAD, STORE
|
||||||
from .recipes import R, Rshamt, Ricmp, I, Iicmp, Iret
|
from .recipes import R, Rshamt, Ricmp, I, Iicmp, Iret, Icopy
|
||||||
from .recipes import U, UJ, UJcall, SB, SBzero, GPsp, GPfi
|
from .recipes import U, UJ, UJcall, SB, SBzero, GPsp, GPfi
|
||||||
from .settings import use_m
|
from .settings import use_m
|
||||||
from cdsl.ast import Var
|
from cdsl.ast import Var
|
||||||
@@ -123,3 +123,8 @@ RV64.enc(base.spill.i64, GPsp, STORE(0b011))
|
|||||||
RV32.enc(base.fill.i32, GPfi, LOAD(0b010))
|
RV32.enc(base.fill.i32, GPfi, LOAD(0b010))
|
||||||
RV64.enc(base.fill.i32, GPfi, LOAD(0b010))
|
RV64.enc(base.fill.i32, GPfi, LOAD(0b010))
|
||||||
RV64.enc(base.fill.i64, GPfi, LOAD(0b011))
|
RV64.enc(base.fill.i64, GPfi, LOAD(0b011))
|
||||||
|
|
||||||
|
# Register copies.
|
||||||
|
RV32.enc(base.copy.i32, Icopy, OPIMM(0b000))
|
||||||
|
RV64.enc(base.copy.i64, Icopy, OPIMM(0b000))
|
||||||
|
RV64.enc(base.copy.i32, Icopy, OPIMM32(0b000))
|
||||||
|
|||||||
@@ -113,6 +113,9 @@ Iicmp = EncRecipe(
|
|||||||
# The variable return values are not encoded.
|
# The variable return values are not encoded.
|
||||||
Iret = EncRecipe('Iret', MultiAry, size=4, ins=(), outs=())
|
Iret = EncRecipe('Iret', MultiAry, size=4, ins=(), outs=())
|
||||||
|
|
||||||
|
# Copy of a GPR is implemented as addi x, 0.
|
||||||
|
Icopy = EncRecipe('Icopy', Unary, size=4, ins=GPR, outs=GPR)
|
||||||
|
|
||||||
# U-type instructions have a 20-bit immediate that targets bits 12-31.
|
# U-type instructions have a 20-bit immediate that targets bits 12-31.
|
||||||
U = EncRecipe(
|
U = EncRecipe(
|
||||||
'U', UnaryImm, size=4, ins=(), outs=GPR,
|
'U', UnaryImm, size=4, ins=(), outs=GPR,
|
||||||
|
|||||||
@@ -182,6 +182,18 @@ fn recipe_iret<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS
|
|||||||
sink);
|
sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn recipe_icopy<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {
|
||||||
|
if let InstructionData::Unary { arg, .. } = func.dfg[inst] {
|
||||||
|
put_i(func.encodings[inst].bits(),
|
||||||
|
func.locations[arg].unwrap_reg(),
|
||||||
|
0,
|
||||||
|
func.locations[func.dfg.first_result(inst)].unwrap_reg(),
|
||||||
|
sink);
|
||||||
|
} else {
|
||||||
|
panic!("Expected Unary format: {:?}", func.dfg[inst]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// U-type instructions.
|
/// U-type instructions.
|
||||||
///
|
///
|
||||||
/// 31 11 6
|
/// 31 11 6
|
||||||
|
|||||||
Reference in New Issue
Block a user