Integer add with carry instructions.

Integer addition with carry in/out/both.
This commit is contained in:
Jakob Stoklund Olesen
2016-09-23 13:32:26 -07:00
parent 7ec54a5a01
commit 9cb3451432
7 changed files with 103 additions and 6 deletions

View File

@@ -13,8 +13,8 @@ use cretonne::ir::{Function, Ebb, Opcode, Value, Type, FunctionName, StackSlotDa
use cretonne::ir::types::{VOID, Signature, ArgumentType, ArgumentExtension};
use cretonne::ir::immediates::{Imm64, Ieee32, Ieee64};
use cretonne::ir::entities::{AnyEntity, NO_EBB, NO_INST, NO_VALUE};
use cretonne::ir::instructions::{InstructionFormat, InstructionData, VariableArgs, JumpData,
BranchData, ReturnData};
use cretonne::ir::instructions::{InstructionFormat, InstructionData, VariableArgs,
TernaryOverflowData, JumpData, BranchData, ReturnData};
use cretonne::isa;
use cretonne::settings;
use testfile::{TestFile, Details, Comment};
@@ -138,6 +138,10 @@ impl Context {
try!(self.map.rewrite_values(args, loc));
}
InstructionData::TernaryOverflow { ref mut data, .. } => {
try!(self.map.rewrite_values(&mut data.args, loc));
}
InstructionData::Jump { ref mut data, .. } => {
try!(self.map.rewrite_ebb(&mut data.destination, loc));
try!(self.map.rewrite_values(&mut data.arguments, loc));
@@ -1066,6 +1070,22 @@ impl<'a> Parser<'a> {
args: [ctrl_arg, true_arg, false_arg],
}
}
InstructionFormat::TernaryOverflow => {
// Names here refer to the `iadd_carry` instruction.
let lhs = try!(self.match_value("expected SSA value first operand"));
try!(self.match_token(Token::Comma, "expected ',' between operands"));
let rhs = try!(self.match_value("expected SSA value second operand"));
try!(self.match_token(Token::Comma, "expected ',' between operands"));
let cin = try!(self.match_value("expected SSA value third operand"));
InstructionData::TernaryOverflow {
opcode: opcode,
ty: VOID,
data: Box::new(TernaryOverflowData {
second_result: NO_VALUE,
args: [lhs, rhs, cin],
}),
}
}
InstructionFormat::Jump => {
// Parse the destination EBB number. Don't translate source to local numbers yet.
let ebb_num = try!(self.match_ebb("expected jump destination EBB"));