Legalize brz.i128 and brnz.i128

This commit is contained in:
bjorn3
2019-06-29 16:38:53 +02:00
committed by Dan Gohman
parent 83ac6dd4d4
commit 762b5e494b
3 changed files with 54 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ use crate::cdsl::xform::{TransformGroupBuilder, TransformGroups};
use crate::shared::immediates::Immediates;
use crate::shared::types::Float::{F32, F64};
use crate::shared::types::Int::{I16, I32, I64, I8};
use crate::shared::types::Int::{I16, I128, I32, I64, I8};
pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGroups {
let mut narrow = TransformGroupBuilder::new(
@@ -49,6 +49,8 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
let bor = insts.by_name("bor");
let bor_imm = insts.by_name("bor_imm");
let bor_not = insts.by_name("bor_not");
let brnz = insts.by_name("brnz");
let brz = insts.by_name("brz");
let br_icmp = insts.by_name("br_icmp");
let br_table = insts.by_name("br_table");
let bxor = insts.by_name("bxor");
@@ -177,9 +179,11 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
let al = var("al");
let ah = var("ah");
let cc = var("cc");
let ebb = var("ebb");
let ptr = var("ptr");
let flags = var("flags");
let offset = var("off");
let vararg = var("vararg");
narrow.legalize(
def!(a = iadd(x, y)),
@@ -227,6 +231,26 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
],
);
narrow.legalize(
def!(brz.I128(x, ebb, vararg)),
vec![
def!((xl, xh) = isplit(x)),
def!(a = icmp_imm(Literal::enumerator_for(intcc, "eq"), xl, Literal::constant(imm64, 0))),
def!(b = icmp_imm(Literal::enumerator_for(intcc, "eq"), xh, Literal::constant(imm64, 0))),
def!(c = band(a, b)),
def!(brz(c, ebb, vararg)),
],
);
narrow.legalize(
def!(brnz.I128(x, ebb, vararg)),
vec![
def!((xl, xh) = isplit(x)),
def!(brnz(xl, ebb, vararg)),
def!(brnz(xh, ebb, vararg)),
],
);
// Widen instructions with one input operand.
for &op in &[bnot, popcnt] {
for &int_ty in &[I8, I16] {