Add a bconst instruction. (#116)

* Add a bconst instruction.
This commit is contained in:
Dan Gohman
2017-07-13 10:12:25 -07:00
committed by Jakob Stoklund Olesen
parent 5cbcd59cf0
commit 5a4aa11274
9 changed files with 64 additions and 2 deletions

View File

@@ -498,6 +498,20 @@ impl<'a> Parser<'a> {
}
}
// Match and consume a boolean immediate.
fn match_bool(&mut self, err_msg: &str) -> Result<bool> {
if let Some(Token::Identifier(text)) = self.token() {
self.consume();
match text {
"true" => Ok(true),
"false" => Ok(false),
_ => err!(self.loc, err_msg),
}
} else {
err!(self.loc, err_msg)
}
}
// Match and consume an enumerated immediate, like one of the condition codes.
fn match_enum<T: FromStr>(&mut self, err_msg: &str) -> Result<T> {
if let Some(Token::Identifier(text)) = self.token() {
@@ -1483,6 +1497,12 @@ impl<'a> Parser<'a> {
imm: self.match_ieee64("expected immediate 64-bit float operand")?,
}
}
InstructionFormat::UnaryBool => {
InstructionData::UnaryBool {
opcode,
imm: self.match_bool("expected immediate boolean operand")?,
}
}
InstructionFormat::Binary => {
let lhs = self.match_value("expected SSA value first operand")?;
self.match_token(Token::Comma, "expected ',' between operands")?;