Add Intel iconst.i32 encoding.
This commit is contained in:
@@ -9,8 +9,10 @@ isa intel
|
||||
|
||||
function %I32() {
|
||||
ebb0:
|
||||
[-,%rcx] v1 = iconst.i32 1
|
||||
[-,%rsi] v2 = iconst.i32 2
|
||||
; asm: movl $1, %ecx
|
||||
[-,%rcx] v1 = iconst.i32 1 ; bin: b9 00000001
|
||||
; asm: movl $2, %esi
|
||||
[-,%rsi] v2 = iconst.i32 2 ; bin: be 00000002
|
||||
|
||||
; Integer Register-Register Operations.
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ for inst, rrr in [
|
||||
I32.enc(inst, *r.rib(0x83, rrr=rrr))
|
||||
I32.enc(inst, *r.rid(0x81, rrr=rrr))
|
||||
|
||||
# Immediate constant.
|
||||
I32.enc(base.iconst.i32, *r.uid(0xb8))
|
||||
|
||||
# 32-bit shifts and rotates.
|
||||
# Note that the dynamic shift amount is only masked by 5 or 6 bits; the 8-bit
|
||||
# and 16-bit shifts would need explicit masking.
|
||||
|
||||
@@ -4,7 +4,7 @@ Intel Encoding recipes.
|
||||
from __future__ import absolute_import
|
||||
from cdsl.isa import EncRecipe
|
||||
from cdsl.predicates import IsSignedInt, IsEqual
|
||||
from base.formats import Binary, BinaryImm, Store, Load
|
||||
from base.formats import UnaryImm, Binary, BinaryImm, Store, Load
|
||||
from .registers import GPR, ABCD
|
||||
|
||||
try:
|
||||
@@ -155,6 +155,11 @@ rid = TailRecipe(
|
||||
'rid', BinaryImm, size=5, ins=GPR, outs=0,
|
||||
instp=IsSignedInt(BinaryImm.imm, 32))
|
||||
|
||||
# XX+rd id unary with 32-bit immediate.
|
||||
uid = TailRecipe(
|
||||
'uid', UnaryImm, size=4, ins=(), outs=GPR,
|
||||
instp=IsSignedInt(UnaryImm.imm, 32))
|
||||
|
||||
#
|
||||
# Store recipes.
|
||||
#
|
||||
|
||||
@@ -133,6 +133,19 @@ fn recipe_op1rid<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut
|
||||
}
|
||||
}
|
||||
|
||||
fn recipe_op1uid<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {
|
||||
if let InstructionData::UnaryImm { imm, .. } = func.dfg[inst] {
|
||||
let bits = func.encodings[inst].bits();
|
||||
let reg = func.locations[func.dfg.first_result(inst)].unwrap_reg();
|
||||
// The destination register is encoded in the low bits of the opcode. No ModR/M
|
||||
put_op1(bits | (reg & 7), sink);
|
||||
let imm: i64 = imm.into();
|
||||
sink.put4(imm as u32);
|
||||
} else {
|
||||
panic!("Expected UnaryImm format: {:?}", func.dfg[inst]);
|
||||
}
|
||||
}
|
||||
|
||||
// Store recipes.
|
||||
|
||||
fn recipe_op1st<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {
|
||||
|
||||
Reference in New Issue
Block a user