Rename BinaryImm format to BinaryImm64
This commit is contained in:
@@ -64,7 +64,7 @@ pub(crate) fn define(shared_defs: &SharedDefinitions, regs: &IsaRegs) -> RecipeG
|
|||||||
|
|
||||||
// R-type with an immediate shift amount instead of rs2.
|
// R-type with an immediate shift amount instead of rs2.
|
||||||
recipes.push(
|
recipes.push(
|
||||||
EncodingRecipeBuilder::new("Rshamt", &formats.binary_imm, 4)
|
EncodingRecipeBuilder::new("Rshamt", &formats.binary_imm64, 4)
|
||||||
.operands_in(vec![gpr])
|
.operands_in(vec![gpr])
|
||||||
.operands_out(vec![gpr])
|
.operands_out(vec![gpr])
|
||||||
.emit("put_rshamt(bits, in_reg0, imm.into(), out_reg0, sink);"),
|
.emit("put_rshamt(bits, in_reg0, imm.into(), out_reg0, sink);"),
|
||||||
@@ -79,11 +79,11 @@ pub(crate) fn define(shared_defs: &SharedDefinitions, regs: &IsaRegs) -> RecipeG
|
|||||||
);
|
);
|
||||||
|
|
||||||
recipes.push(
|
recipes.push(
|
||||||
EncodingRecipeBuilder::new("Ii", &formats.binary_imm, 4)
|
EncodingRecipeBuilder::new("Ii", &formats.binary_imm64, 4)
|
||||||
.operands_in(vec![gpr])
|
.operands_in(vec![gpr])
|
||||||
.operands_out(vec![gpr])
|
.operands_out(vec![gpr])
|
||||||
.inst_predicate(InstructionPredicate::new_is_signed_int(
|
.inst_predicate(InstructionPredicate::new_is_signed_int(
|
||||||
&*formats.binary_imm,
|
&*formats.binary_imm64,
|
||||||
"imm",
|
"imm",
|
||||||
12,
|
12,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -926,11 +926,11 @@ pub(crate) fn define<'shared>(
|
|||||||
// XX /n ib with 8-bit immediate sign-extended.
|
// XX /n ib with 8-bit immediate sign-extended.
|
||||||
{
|
{
|
||||||
recipes.add_template_inferred(
|
recipes.add_template_inferred(
|
||||||
EncodingRecipeBuilder::new("r_ib", &formats.binary_imm, 2)
|
EncodingRecipeBuilder::new("r_ib", &formats.binary_imm64, 2)
|
||||||
.operands_in(vec![gpr])
|
.operands_in(vec![gpr])
|
||||||
.operands_out(vec![0])
|
.operands_out(vec![0])
|
||||||
.inst_predicate(InstructionPredicate::new_is_signed_int(
|
.inst_predicate(InstructionPredicate::new_is_signed_int(
|
||||||
&*formats.binary_imm,
|
&*formats.binary_imm64,
|
||||||
"imm",
|
"imm",
|
||||||
8,
|
8,
|
||||||
0,
|
0,
|
||||||
@@ -947,11 +947,11 @@ pub(crate) fn define<'shared>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
recipes.add_template_inferred(
|
recipes.add_template_inferred(
|
||||||
EncodingRecipeBuilder::new("f_ib", &formats.binary_imm, 2)
|
EncodingRecipeBuilder::new("f_ib", &formats.binary_imm64, 2)
|
||||||
.operands_in(vec![fpr])
|
.operands_in(vec![fpr])
|
||||||
.operands_out(vec![0])
|
.operands_out(vec![0])
|
||||||
.inst_predicate(InstructionPredicate::new_is_signed_int(
|
.inst_predicate(InstructionPredicate::new_is_signed_int(
|
||||||
&*formats.binary_imm,
|
&*formats.binary_imm64,
|
||||||
"imm",
|
"imm",
|
||||||
8,
|
8,
|
||||||
0,
|
0,
|
||||||
@@ -970,11 +970,11 @@ pub(crate) fn define<'shared>(
|
|||||||
// XX /n id with 32-bit immediate sign-extended.
|
// XX /n id with 32-bit immediate sign-extended.
|
||||||
recipes.add_template(
|
recipes.add_template(
|
||||||
Template::new(
|
Template::new(
|
||||||
EncodingRecipeBuilder::new("r_id", &formats.binary_imm, 5)
|
EncodingRecipeBuilder::new("r_id", &formats.binary_imm64, 5)
|
||||||
.operands_in(vec![gpr])
|
.operands_in(vec![gpr])
|
||||||
.operands_out(vec![0])
|
.operands_out(vec![0])
|
||||||
.inst_predicate(InstructionPredicate::new_is_signed_int(
|
.inst_predicate(InstructionPredicate::new_is_signed_int(
|
||||||
&*formats.binary_imm,
|
&*formats.binary_imm64,
|
||||||
"imm",
|
"imm",
|
||||||
32,
|
32,
|
||||||
0,
|
0,
|
||||||
@@ -2874,12 +2874,12 @@ pub(crate) fn define<'shared>(
|
|||||||
|
|
||||||
{
|
{
|
||||||
let has_small_offset =
|
let has_small_offset =
|
||||||
InstructionPredicate::new_is_signed_int(&*formats.binary_imm, "imm", 8, 0);
|
InstructionPredicate::new_is_signed_int(&*formats.binary_imm64, "imm", 8, 0);
|
||||||
|
|
||||||
// XX /n, MI form with imm8.
|
// XX /n, MI form with imm8.
|
||||||
recipes.add_template(
|
recipes.add_template(
|
||||||
Template::new(
|
Template::new(
|
||||||
EncodingRecipeBuilder::new("rcmp_ib", &formats.binary_imm, 2)
|
EncodingRecipeBuilder::new("rcmp_ib", &formats.binary_imm64, 2)
|
||||||
.operands_in(vec![gpr])
|
.operands_in(vec![gpr])
|
||||||
.operands_out(vec![reg_rflags])
|
.operands_out(vec![reg_rflags])
|
||||||
.inst_predicate(has_small_offset)
|
.inst_predicate(has_small_offset)
|
||||||
@@ -2897,12 +2897,12 @@ pub(crate) fn define<'shared>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
let has_big_offset =
|
let has_big_offset =
|
||||||
InstructionPredicate::new_is_signed_int(&*formats.binary_imm, "imm", 32, 0);
|
InstructionPredicate::new_is_signed_int(&*formats.binary_imm64, "imm", 32, 0);
|
||||||
|
|
||||||
// XX /n, MI form with imm32.
|
// XX /n, MI form with imm32.
|
||||||
recipes.add_template(
|
recipes.add_template(
|
||||||
Template::new(
|
Template::new(
|
||||||
EncodingRecipeBuilder::new("rcmp_id", &formats.binary_imm, 5)
|
EncodingRecipeBuilder::new("rcmp_id", &formats.binary_imm64, 5)
|
||||||
.operands_in(vec![gpr])
|
.operands_in(vec![gpr])
|
||||||
.operands_out(vec![reg_rflags])
|
.operands_out(vec![reg_rflags])
|
||||||
.inst_predicate(has_big_offset)
|
.inst_predicate(has_big_offset)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::rc::Rc;
|
|||||||
|
|
||||||
pub(crate) struct Formats {
|
pub(crate) struct Formats {
|
||||||
pub(crate) binary: Rc<InstructionFormat>,
|
pub(crate) binary: Rc<InstructionFormat>,
|
||||||
pub(crate) binary_imm: Rc<InstructionFormat>,
|
pub(crate) binary_imm64: Rc<InstructionFormat>,
|
||||||
pub(crate) branch: Rc<InstructionFormat>,
|
pub(crate) branch: Rc<InstructionFormat>,
|
||||||
pub(crate) branch_float: Rc<InstructionFormat>,
|
pub(crate) branch_float: Rc<InstructionFormat>,
|
||||||
pub(crate) branch_icmp: Rc<InstructionFormat>,
|
pub(crate) branch_icmp: Rc<InstructionFormat>,
|
||||||
@@ -78,7 +78,7 @@ impl Formats {
|
|||||||
|
|
||||||
binary_imm8: Builder::new("BinaryImm8").value().imm(&imm.uimm8).build(),
|
binary_imm8: Builder::new("BinaryImm8").value().imm(&imm.uimm8).build(),
|
||||||
|
|
||||||
binary_imm: Builder::new("BinaryImm").value().imm(&imm.imm64).build(),
|
binary_imm64: Builder::new("BinaryImm64").value().imm(&imm.imm64).build(),
|
||||||
|
|
||||||
// The select instructions are controlled by the second VALUE operand.
|
// The select instructions are controlled by the second VALUE operand.
|
||||||
// The first VALUE operand is the controlling flag which has a derived type.
|
// The first VALUE operand is the controlling flag which has a derived type.
|
||||||
|
|||||||
@@ -2215,7 +2215,7 @@ pub(crate) fn define(
|
|||||||
Like `icmp_imm`, but returns integer CPU flags instead of testing
|
Like `icmp_imm`, but returns integer CPU flags instead of testing
|
||||||
a specific condition code.
|
a specific condition code.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![f]),
|
.operands_out(vec![f]),
|
||||||
@@ -2460,7 +2460,7 @@ pub(crate) fn define(
|
|||||||
Polymorphic over all scalar integer types, but does not support vector
|
Polymorphic over all scalar integer types, but does not support vector
|
||||||
types.
|
types.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2475,7 +2475,7 @@ pub(crate) fn define(
|
|||||||
Polymorphic over all scalar integer types, but does not support vector
|
Polymorphic over all scalar integer types, but does not support vector
|
||||||
types.
|
types.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2489,7 +2489,7 @@ pub(crate) fn define(
|
|||||||
|
|
||||||
This operation traps if the divisor is zero.
|
This operation traps if the divisor is zero.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2505,7 +2505,7 @@ pub(crate) fn define(
|
|||||||
representable in `B` bits two's complement. This only happens
|
representable in `B` bits two's complement. This only happens
|
||||||
when `x = -2^{B-1}, Y = -1`.
|
when `x = -2^{B-1}, Y = -1`.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2519,7 +2519,7 @@ pub(crate) fn define(
|
|||||||
|
|
||||||
This operation traps if the divisor is zero.
|
This operation traps if the divisor is zero.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2533,7 +2533,7 @@ pub(crate) fn define(
|
|||||||
|
|
||||||
This operation traps if the divisor is zero.
|
This operation traps if the divisor is zero.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2552,7 +2552,7 @@ pub(crate) fn define(
|
|||||||
Polymorphic over all scalar integer types, but does not support vector
|
Polymorphic over all scalar integer types, but does not support vector
|
||||||
types.
|
types.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2952,7 +2952,7 @@ pub(crate) fn define(
|
|||||||
Polymorphic over all scalar integer types, but does not support vector
|
Polymorphic over all scalar integer types, but does not support vector
|
||||||
types.
|
types.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2969,7 +2969,7 @@ pub(crate) fn define(
|
|||||||
Polymorphic over all scalar integer types, but does not support vector
|
Polymorphic over all scalar integer types, but does not support vector
|
||||||
types.
|
types.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -2986,7 +2986,7 @@ pub(crate) fn define(
|
|||||||
Polymorphic over all scalar integer types, but does not support vector
|
Polymorphic over all scalar integer types, but does not support vector
|
||||||
types.
|
types.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -3031,7 +3031,7 @@ pub(crate) fn define(
|
|||||||
r#"
|
r#"
|
||||||
Rotate left by immediate.
|
Rotate left by immediate.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -3043,7 +3043,7 @@ pub(crate) fn define(
|
|||||||
r#"
|
r#"
|
||||||
Rotate right by immediate.
|
Rotate right by immediate.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -3118,7 +3118,7 @@ pub(crate) fn define(
|
|||||||
|
|
||||||
The shift amount is masked to the size of ``x``.
|
The shift amount is masked to the size of ``x``.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -3132,7 +3132,7 @@ pub(crate) fn define(
|
|||||||
|
|
||||||
The shift amount is masked to the size of the register.
|
The shift amount is masked to the size of the register.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
@@ -3146,7 +3146,7 @@ pub(crate) fn define(
|
|||||||
|
|
||||||
The shift amount is masked to the size of the register.
|
The shift amount is masked to the size of the register.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary_imm,
|
&formats.binary_imm64,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, Y])
|
.operands_in(vec![x, Y])
|
||||||
.operands_out(vec![a]),
|
.operands_out(vec![a]),
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ impl InstructionData {
|
|||||||
let bit_width = ctrl_typevar.bits();
|
let bit_width = ctrl_typevar.bits();
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Self::BinaryImm {
|
Self::BinaryImm64 {
|
||||||
opcode,
|
opcode,
|
||||||
arg: _,
|
arg: _,
|
||||||
imm,
|
imm,
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ mod tests {
|
|||||||
let arg32 = func.dfg.append_block_param(block, types::I32);
|
let arg32 = func.dfg.append_block_param(block, types::I32);
|
||||||
|
|
||||||
// Try to encode iadd_imm.i64 v1, -10.
|
// Try to encode iadd_imm.i64 v1, -10.
|
||||||
let inst64 = InstructionData::BinaryImm {
|
let inst64 = InstructionData::BinaryImm64 {
|
||||||
opcode: Opcode::IaddImm,
|
opcode: Opcode::IaddImm,
|
||||||
arg: arg64,
|
arg: arg64,
|
||||||
imm: immediates::Imm64::new(-10),
|
imm: immediates::Imm64::new(-10),
|
||||||
@@ -176,7 +176,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Try to encode iadd_imm.i64 v1, -10000.
|
// Try to encode iadd_imm.i64 v1, -10000.
|
||||||
let inst64_large = InstructionData::BinaryImm {
|
let inst64_large = InstructionData::BinaryImm64 {
|
||||||
opcode: Opcode::IaddImm,
|
opcode: Opcode::IaddImm,
|
||||||
arg: arg64,
|
arg: arg64,
|
||||||
imm: immediates::Imm64::new(-10000),
|
imm: immediates::Imm64::new(-10000),
|
||||||
@@ -186,7 +186,7 @@ mod tests {
|
|||||||
assert!(isa.encode(&func, &inst64_large, types::I64).is_err());
|
assert!(isa.encode(&func, &inst64_large, types::I64).is_err());
|
||||||
|
|
||||||
// Create an iadd_imm.i32 which is encodable in RV64.
|
// Create an iadd_imm.i32 which is encodable in RV64.
|
||||||
let inst32 = InstructionData::BinaryImm {
|
let inst32 = InstructionData::BinaryImm64 {
|
||||||
opcode: Opcode::IaddImm,
|
opcode: Opcode::IaddImm,
|
||||||
arg: arg32,
|
arg: arg32,
|
||||||
imm: immediates::Imm64::new(10),
|
imm: immediates::Imm64::new(10),
|
||||||
@@ -214,7 +214,7 @@ mod tests {
|
|||||||
let arg32 = func.dfg.append_block_param(block, types::I32);
|
let arg32 = func.dfg.append_block_param(block, types::I32);
|
||||||
|
|
||||||
// Try to encode iadd_imm.i64 v1, -10.
|
// Try to encode iadd_imm.i64 v1, -10.
|
||||||
let inst64 = InstructionData::BinaryImm {
|
let inst64 = InstructionData::BinaryImm64 {
|
||||||
opcode: Opcode::IaddImm,
|
opcode: Opcode::IaddImm,
|
||||||
arg: arg64,
|
arg: arg64,
|
||||||
imm: immediates::Imm64::new(-10),
|
imm: immediates::Imm64::new(-10),
|
||||||
@@ -224,7 +224,7 @@ mod tests {
|
|||||||
assert!(isa.encode(&func, &inst64, types::I64).is_err());
|
assert!(isa.encode(&func, &inst64, types::I64).is_err());
|
||||||
|
|
||||||
// Try to encode iadd_imm.i64 v1, -10000.
|
// Try to encode iadd_imm.i64 v1, -10000.
|
||||||
let inst64_large = InstructionData::BinaryImm {
|
let inst64_large = InstructionData::BinaryImm64 {
|
||||||
opcode: Opcode::IaddImm,
|
opcode: Opcode::IaddImm,
|
||||||
arg: arg64,
|
arg: arg64,
|
||||||
imm: immediates::Imm64::new(-10000),
|
imm: immediates::Imm64::new(-10000),
|
||||||
@@ -234,7 +234,7 @@ mod tests {
|
|||||||
assert!(isa.encode(&func, &inst64_large, types::I64).is_err());
|
assert!(isa.encode(&func, &inst64_large, types::I64).is_err());
|
||||||
|
|
||||||
// Create an iadd_imm.i32 which is encodable in RV32.
|
// Create an iadd_imm.i32 which is encodable in RV32.
|
||||||
let inst32 = InstructionData::BinaryImm {
|
let inst32 = InstructionData::BinaryImm64 {
|
||||||
opcode: Opcode::IaddImm,
|
opcode: Opcode::IaddImm,
|
||||||
arg: arg32,
|
arg: arg32,
|
||||||
imm: immediates::Imm64::new(10),
|
imm: immediates::Imm64::new(10),
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ fn intcc_to_peepmatic(cc: IntCC) -> ConditionCode {
|
|||||||
|
|
||||||
fn get_immediate(dfg: &DataFlowGraph, inst: Inst, i: usize) -> Part<ValueOrInst> {
|
fn get_immediate(dfg: &DataFlowGraph, inst: Inst, i: usize) -> Part<ValueOrInst> {
|
||||||
return match dfg[inst] {
|
return match dfg[inst] {
|
||||||
InstructionData::BinaryImm { imm, .. } if i == 0 => imm.into(),
|
InstructionData::BinaryImm64 { imm, .. } if i == 0 => imm.into(),
|
||||||
InstructionData::BranchIcmp { cond, .. } if i == 0 => intcc_to_peepmatic(cond).into(),
|
InstructionData::BranchIcmp { cond, .. } if i == 0 => intcc_to_peepmatic(cond).into(),
|
||||||
InstructionData::BranchInt { cond, .. } if i == 0 => intcc_to_peepmatic(cond).into(),
|
InstructionData::BranchInt { cond, .. } if i == 0 => intcc_to_peepmatic(cond).into(),
|
||||||
InstructionData::IntCompare { cond, .. } if i == 0 => intcc_to_peepmatic(cond).into(),
|
InstructionData::IntCompare { cond, .. } if i == 0 => intcc_to_peepmatic(cond).into(),
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ fn optimize_complex_addresses(pos: &mut EncCursor, inst: Inst, isa: &dyn TargetI
|
|||||||
}
|
}
|
||||||
_ => panic!("Unsupported load or store opcode"),
|
_ => panic!("Unsupported load or store opcode"),
|
||||||
},
|
},
|
||||||
InstructionData::BinaryImm {
|
InstructionData::BinaryImm64 {
|
||||||
opcode: Opcode::IaddImm,
|
opcode: Opcode::IaddImm,
|
||||||
arg,
|
arg,
|
||||||
imm,
|
imm,
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ fn package_up_divrem_info(
|
|||||||
/// Examine `inst` to see if it is a div or rem by a constant, and if so return the operands,
|
/// Examine `inst` to see if it is a div or rem by a constant, and if so return the operands,
|
||||||
/// signedness, operation size and div-vs-rem-ness in a handy bundle.
|
/// signedness, operation size and div-vs-rem-ness in a handy bundle.
|
||||||
fn get_div_info(inst: Inst, dfg: &DataFlowGraph) -> Option<DivRemByConstInfo> {
|
fn get_div_info(inst: Inst, dfg: &DataFlowGraph) -> Option<DivRemByConstInfo> {
|
||||||
if let InstructionData::BinaryImm { opcode, arg, imm } = dfg[inst] {
|
if let InstructionData::BinaryImm64 { opcode, arg, imm } = dfg[inst] {
|
||||||
let (is_signed, is_rem) = match opcode {
|
let (is_signed, is_rem) = match opcode {
|
||||||
Opcode::UdivImm => (false, false),
|
Opcode::UdivImm => (false, false),
|
||||||
Opcode::UremImm => (false, true),
|
Opcode::UremImm => (false, true),
|
||||||
@@ -704,7 +704,7 @@ mod simplify {
|
|||||||
imm: immediates::Imm64,
|
imm: immediates::Imm64,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let ValueDef::Result(arg_inst, _) = pos.func.dfg.value_def(arg) {
|
if let ValueDef::Result(arg_inst, _) = pos.func.dfg.value_def(arg) {
|
||||||
if let InstructionData::BinaryImm {
|
if let InstructionData::BinaryImm64 {
|
||||||
opcode: Opcode::IshlImm,
|
opcode: Opcode::IshlImm,
|
||||||
arg: prev_arg,
|
arg: prev_arg,
|
||||||
imm: prev_imm,
|
imm: prev_imm,
|
||||||
@@ -784,7 +784,7 @@ mod simplify {
|
|||||||
pos.func
|
pos.func
|
||||||
.dfg
|
.dfg
|
||||||
.replace(inst)
|
.replace(inst)
|
||||||
.BinaryImm(new_opcode, ty, imm, args[0]);
|
.BinaryImm64(new_opcode, ty, imm, args[0]);
|
||||||
|
|
||||||
// Repeat for BinaryImm simplification.
|
// Repeat for BinaryImm simplification.
|
||||||
simplify(pos, inst, native_word_width);
|
simplify(pos, inst, native_word_width);
|
||||||
@@ -804,7 +804,7 @@ mod simplify {
|
|||||||
pos.func
|
pos.func
|
||||||
.dfg
|
.dfg
|
||||||
.replace(inst)
|
.replace(inst)
|
||||||
.BinaryImm(new_opcode, ty, imm, args[1]);
|
.BinaryImm64(new_opcode, ty, imm, args[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -818,7 +818,7 @@ mod simplify {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionData::BinaryImm { opcode, arg, imm } => {
|
InstructionData::BinaryImm64 { opcode, arg, imm } => {
|
||||||
let ty = pos.func.dfg.ctrl_typevar(inst);
|
let ty = pos.func.dfg.ctrl_typevar(inst);
|
||||||
|
|
||||||
let mut arg = arg;
|
let mut arg = arg;
|
||||||
@@ -831,7 +831,7 @@ mod simplify {
|
|||||||
| Opcode::BxorImm => {
|
| Opcode::BxorImm => {
|
||||||
// Fold binary_op(C2, binary_op(C1, x)) into binary_op(binary_op(C1, C2), x)
|
// Fold binary_op(C2, binary_op(C1, x)) into binary_op(binary_op(C1, C2), x)
|
||||||
if let ValueDef::Result(arg_inst, _) = pos.func.dfg.value_def(arg) {
|
if let ValueDef::Result(arg_inst, _) = pos.func.dfg.value_def(arg) {
|
||||||
if let InstructionData::BinaryImm {
|
if let InstructionData::BinaryImm64 {
|
||||||
opcode: prev_opcode,
|
opcode: prev_opcode,
|
||||||
arg: prev_arg,
|
arg: prev_arg,
|
||||||
imm: prev_imm,
|
imm: prev_imm,
|
||||||
@@ -855,7 +855,7 @@ mod simplify {
|
|||||||
pos.func
|
pos.func
|
||||||
.dfg
|
.dfg
|
||||||
.replace(inst)
|
.replace(inst)
|
||||||
.BinaryImm(opcode, ty, new_imm, new_arg);
|
.BinaryImm64(opcode, ty, new_imm, new_arg);
|
||||||
imm = new_imm;
|
imm = new_imm;
|
||||||
arg = new_arg;
|
arg = new_arg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -757,7 +757,7 @@ impl<'a> Verifier<'a> {
|
|||||||
| UnaryBool { .. }
|
| UnaryBool { .. }
|
||||||
| Binary { .. }
|
| Binary { .. }
|
||||||
| BinaryImm8 { .. }
|
| BinaryImm8 { .. }
|
||||||
| BinaryImm { .. }
|
| BinaryImm64 { .. }
|
||||||
| Ternary { .. }
|
| Ternary { .. }
|
||||||
| TernaryImm8 { .. }
|
| TernaryImm8 { .. }
|
||||||
| Shuffle { .. }
|
| Shuffle { .. }
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ pub fn write_operands(
|
|||||||
} => write!(w, " {}", constant_handle),
|
} => write!(w, " {}", constant_handle),
|
||||||
Binary { args, .. } => write!(w, " {}, {}", args[0], args[1]),
|
Binary { args, .. } => write!(w, " {}, {}", args[0], args[1]),
|
||||||
BinaryImm8 { arg, imm, .. } => write!(w, " {}, {}", arg, imm),
|
BinaryImm8 { arg, imm, .. } => write!(w, " {}, {}", arg, imm),
|
||||||
BinaryImm { arg, imm, .. } => write!(w, " {}, {}", arg, imm),
|
BinaryImm64 { arg, imm, .. } => write!(w, " {}, {}", arg, imm),
|
||||||
Ternary { args, .. } => write!(w, " {}, {}, {}", args[0], args[1], args[2]),
|
Ternary { args, .. } => write!(w, " {}, {}, {}", args[0], args[1], args[2]),
|
||||||
MultiAry { ref args, .. } => {
|
MultiAry { ref args, .. } => {
|
||||||
if args.is_empty() {
|
if args.is_empty() {
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ impl Interpreter {
|
|||||||
Ok(Continue)
|
Ok(Continue)
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryImm { opcode, arg, imm } => {
|
BinaryImm64 { opcode, arg, imm } => {
|
||||||
let imm = DataValue::from_integer(*imm, type_of(*arg, frame.function))?;
|
let imm = DataValue::from_integer(*imm, type_of(*arg, frame.function))?;
|
||||||
let arg = frame.get(&arg);
|
let arg = frame.get(&arg);
|
||||||
let result = match opcode {
|
let result = match opcode {
|
||||||
|
|||||||
@@ -2758,11 +2758,11 @@ impl<'a> Parser<'a> {
|
|||||||
let imm = self.match_uimm8("expected unsigned 8-bit immediate")?;
|
let imm = self.match_uimm8("expected unsigned 8-bit immediate")?;
|
||||||
InstructionData::BinaryImm8 { opcode, arg, imm }
|
InstructionData::BinaryImm8 { opcode, arg, imm }
|
||||||
}
|
}
|
||||||
InstructionFormat::BinaryImm => {
|
InstructionFormat::BinaryImm64 => {
|
||||||
let lhs = self.match_value("expected SSA value first operand")?;
|
let lhs = self.match_value("expected SSA value first operand")?;
|
||||||
self.match_token(Token::Comma, "expected ',' between operands")?;
|
self.match_token(Token::Comma, "expected ',' between operands")?;
|
||||||
let rhs = self.match_imm64("expected immediate integer second operand")?;
|
let rhs = self.match_imm64("expected immediate integer second operand")?;
|
||||||
InstructionData::BinaryImm {
|
InstructionData::BinaryImm64 {
|
||||||
opcode,
|
opcode,
|
||||||
arg: lhs,
|
arg: lhs,
|
||||||
imm: rhs,
|
imm: rhs,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ pub enum SerInstData {
|
|||||||
arg: String,
|
arg: String,
|
||||||
imm: String,
|
imm: String,
|
||||||
},
|
},
|
||||||
BinaryImm {
|
BinaryImm64 {
|
||||||
opcode: String,
|
opcode: String,
|
||||||
arg: String,
|
arg: String,
|
||||||
imm: String,
|
imm: String,
|
||||||
@@ -297,7 +297,7 @@ pub fn get_inst_data(inst_index: Inst, func: &Function) -> SerInstData {
|
|||||||
arg: arg.to_string(),
|
arg: arg.to_string(),
|
||||||
imm: imm.to_string(),
|
imm: imm.to_string(),
|
||||||
},
|
},
|
||||||
InstructionData::BinaryImm { opcode, arg, imm } => SerInstData::BinaryImm {
|
InstructionData::BinaryImm64 { opcode, arg, imm } => SerInstData::BinaryImm64 {
|
||||||
opcode: opcode.to_string(),
|
opcode: opcode.to_string(),
|
||||||
arg: arg.to_string(),
|
arg: arg.to_string(),
|
||||||
imm: imm.to_string(),
|
imm: imm.to_string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user