Add a BinaryOverflow instruction format.
This will eventualy be used for add-with-carry and add-with-overflow type instructions. For now it only serves as a representative of instruction formats that have multiple_results=True and boxed_storage=False at the same time.
This commit is contained in:
@@ -133,13 +133,19 @@ pub enum InstructionData {
|
|||||||
lhs: Value,
|
lhs: Value,
|
||||||
rhs: Imm64,
|
rhs: Imm64,
|
||||||
},
|
},
|
||||||
// Same as BinaryImm, but the imediate is the lhs operand.
|
// Same as BinaryImm, but the immediate is the lhs operand.
|
||||||
BinaryImmRev {
|
BinaryImmRev {
|
||||||
opcode: Opcode,
|
opcode: Opcode,
|
||||||
ty: Type,
|
ty: Type,
|
||||||
rhs: Value,
|
rhs: Value,
|
||||||
lhs: Imm64,
|
lhs: Imm64,
|
||||||
},
|
},
|
||||||
|
BinaryOverflow {
|
||||||
|
opcode: Opcode,
|
||||||
|
ty: Type,
|
||||||
|
second_result: Value,
|
||||||
|
args: [Value; 2],
|
||||||
|
},
|
||||||
Jump {
|
Jump {
|
||||||
opcode: Opcode,
|
opcode: Opcode,
|
||||||
ty: Type,
|
ty: Type,
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ pub fn write_instruction(w: &mut Write, func: &Function, inst: Inst) -> Result {
|
|||||||
Binary { opcode, args, .. } => writeln!(w, "{} {}, {}", opcode, args[0], args[1]),
|
Binary { opcode, args, .. } => writeln!(w, "{} {}, {}", opcode, args[0], args[1]),
|
||||||
BinaryImm { opcode, lhs, rhs, .. } => writeln!(w, "{} {}, {}", opcode, lhs, rhs),
|
BinaryImm { opcode, lhs, rhs, .. } => writeln!(w, "{} {}, {}", opcode, lhs, rhs),
|
||||||
BinaryImmRev { opcode, lhs, rhs, .. } => writeln!(w, "{} {}, {}", opcode, lhs, rhs),
|
BinaryImmRev { opcode, lhs, rhs, .. } => writeln!(w, "{} {}, {}", opcode, lhs, rhs),
|
||||||
|
BinaryOverflow { opcode, args, .. } => writeln!(w, "{} {}, {}", opcode, args[0], args[1]),
|
||||||
Jump { opcode, ref data, .. } => writeln!(w, "{} {}", opcode, data),
|
Jump { opcode, ref data, .. } => writeln!(w, "{} {}", opcode, data),
|
||||||
Branch { opcode, ref data, .. } => writeln!(w, "{} {}", opcode, data),
|
Branch { opcode, ref data, .. } => writeln!(w, "{} {}", opcode, data),
|
||||||
BranchTable { opcode, arg, table, .. } => writeln!(w, "{} {}, {}", opcode, arg, table),
|
BranchTable { opcode, arg, table, .. } => writeln!(w, "{} {}, {}", opcode, arg, table),
|
||||||
|
|||||||
@@ -657,6 +657,17 @@ impl<'a> Parser<'a> {
|
|||||||
rhs: rhs,
|
rhs: rhs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
InstructionFormat::BinaryOverflow => {
|
||||||
|
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"));
|
||||||
|
InstructionData::BinaryOverflow {
|
||||||
|
opcode: opcode,
|
||||||
|
ty: VOID,
|
||||||
|
second_result: NO_VALUE,
|
||||||
|
args: [lhs, rhs],
|
||||||
|
}
|
||||||
|
}
|
||||||
InstructionFormat::Jump |
|
InstructionFormat::Jump |
|
||||||
InstructionFormat::Branch |
|
InstructionFormat::Branch |
|
||||||
InstructionFormat::BranchTable |
|
InstructionFormat::BranchTable |
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ Binary = InstructionFormat(value, value)
|
|||||||
BinaryImm = InstructionFormat(value, imm64)
|
BinaryImm = InstructionFormat(value, imm64)
|
||||||
BinaryImmRev = InstructionFormat(imm64, value)
|
BinaryImmRev = InstructionFormat(imm64, value)
|
||||||
|
|
||||||
|
# Generate result + overflow flag.
|
||||||
|
BinaryOverflow = InstructionFormat(value, value, multiple_results=True)
|
||||||
|
|
||||||
Jump = InstructionFormat(ebb, variable_args, boxed_storage=True)
|
Jump = InstructionFormat(ebb, variable_args, boxed_storage=True)
|
||||||
Branch = InstructionFormat(value, ebb, variable_args, boxed_storage=True)
|
Branch = InstructionFormat(value, ebb, variable_args, boxed_storage=True)
|
||||||
BranchTable = InstructionFormat(value, jump_table)
|
BranchTable = InstructionFormat(value, jump_table)
|
||||||
|
|||||||
Reference in New Issue
Block a user