[codegen] add to_static_str method to IntCC
Add a method to_static_str to objects of type IntCC which consumes the object to basically do the opposite of IntCC::new. Refs: https://github.com/CraneStation/cranelift/pull/1081#discussion_r329042331
This commit is contained in:
committed by
Benjamin Bouvier
parent
c8128539d0
commit
19444649e7
@@ -95,10 +95,11 @@ impl CondCode for IntCC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for IntCC {
|
impl IntCC {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
/// Get the corresponding string condition code for the IntCC object.
|
||||||
|
pub fn to_static_str(self) -> &'static str {
|
||||||
use self::IntCC::*;
|
use self::IntCC::*;
|
||||||
f.write_str(match *self {
|
match self {
|
||||||
Equal => "eq",
|
Equal => "eq",
|
||||||
NotEqual => "ne",
|
NotEqual => "ne",
|
||||||
SignedGreaterThan => "sgt",
|
SignedGreaterThan => "sgt",
|
||||||
@@ -111,7 +112,13 @@ impl Display for IntCC {
|
|||||||
UnsignedLessThanOrEqual => "ule",
|
UnsignedLessThanOrEqual => "ule",
|
||||||
Overflow => "of",
|
Overflow => "of",
|
||||||
NotOverflow => "nof",
|
NotOverflow => "nof",
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for IntCC {
|
||||||
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
|
f.write_str(self.to_static_str())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user