Parse select instructions.

This commit is contained in:
Jakob Stoklund Olesen
2016-07-05 16:51:26 -07:00
parent 473e708dce
commit f18e5fe0fa
3 changed files with 23 additions and 1 deletions

View File

@@ -791,6 +791,18 @@ impl<'a> Parser<'a> {
args: [lhs, rhs], args: [lhs, rhs],
} }
} }
InstructionFormat::Select => {
let ctrl_arg = try!(self.match_value("expected SSA value control operand"));
try!(self.match_token(Token::Comma, "expected ',' between operands"));
let true_arg = try!(self.match_value("expected SSA value true operand"));
try!(self.match_token(Token::Comma, "expected ',' between operands"));
let false_arg = try!(self.match_value("expected SSA value false operand"));
InstructionData::Select {
opcode: opcode,
ty: VOID,
args: [ctrl_arg, true_arg, false_arg],
}
}
InstructionFormat::Jump => { InstructionFormat::Jump => {
// Parse the destination EBB number. Don't translate source to local numbers yet. // Parse the destination EBB number. Don't translate source to local numbers yet.
let ebb_num = try!(self.match_ebb("expected jump destination EBB")); let ebb_num = try!(self.match_ebb("expected jump destination EBB"));
@@ -819,7 +831,6 @@ impl<'a> Parser<'a> {
}), }),
} }
} }
InstructionFormat::Select |
InstructionFormat::InsertLane | InstructionFormat::InsertLane |
InstructionFormat::ExtractLane | InstructionFormat::ExtractLane |
InstructionFormat::BranchTable | InstructionFormat::BranchTable |

View File

@@ -12,3 +12,9 @@ ebb0:
v1 = iconst.i8 6 v1 = iconst.i8 6
v2 = ishl v0, v1 v2 = ishl v0, v1
} }
; Polymorphic istruction controlled by second operand.
function select() {
ebb0(vx0: i32, vx1:i32, vx2: b1):
v0 = select vx2, vx0, vx1
}

View File

@@ -9,3 +9,8 @@ ebb0:
v1 = iconst.i8 6 v1 = iconst.i8 6
v2 = ishl v0, v1 v2 = ishl v0, v1
} }
function select() {
ebb0(vx0: i32, vx1: i32, vx2: b1):
v0 = select vx2, vx0, vx1
}