Add legalization patterns for fabs and fneg.
These sign bit manipulations need to use a -0.0 floating point constant which we didn't have a way of materializing previously. Add a ieee32.bits(0x...) syntax to the Python AST nodes that creates am f32 immediate value with the exact requested bitwise representation.
This commit is contained in:
@@ -502,6 +502,27 @@ class ConstantInt(Literal):
|
||||
return str(self.value)
|
||||
|
||||
|
||||
class ConstantBits(Literal):
|
||||
"""
|
||||
A bitwise value of an immediate operand.
|
||||
|
||||
This is used to create bitwise exact floating point constants using
|
||||
`ieee32.bits(0x80000000)`.
|
||||
"""
|
||||
|
||||
def __init__(self, kind, bits):
|
||||
# type: (ImmediateKind, int) -> None
|
||||
v = '{}::with_bits({:#x})'.format(kind.rust_type, bits)
|
||||
super(ConstantBits, self).__init__(kind, v)
|
||||
|
||||
def __str__(self):
|
||||
# type: () -> str
|
||||
"""
|
||||
Get the Rust expression form of this constant.
|
||||
"""
|
||||
return str(self.value)
|
||||
|
||||
|
||||
class Enumerator(Literal):
|
||||
"""
|
||||
A value of an enumerated immediate operand.
|
||||
|
||||
@@ -8,7 +8,7 @@ try:
|
||||
from typing import Union, Dict, TYPE_CHECKING, Iterable # noqa
|
||||
OperandSpec = Union['OperandKind', ValueType, TypeVar]
|
||||
if TYPE_CHECKING:
|
||||
from .ast import Enumerator, ConstantInt, Literal # noqa
|
||||
from .ast import Enumerator, ConstantInt, ConstantBits, Literal # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -123,6 +123,15 @@ class ImmediateKind(OperandKind):
|
||||
.format(self.name, value))
|
||||
return ConstantInt(self, value)
|
||||
|
||||
def bits(self, bits):
|
||||
# type: (int) -> ConstantBits
|
||||
"""
|
||||
Create an AST literal node for the given bitwise representation of this
|
||||
immediate operand kind.
|
||||
"""
|
||||
from .ast import ConstantBits # noqa
|
||||
return ConstantBits(self, bits)
|
||||
|
||||
def rust_enumerator(self, value):
|
||||
# type: (str) -> str
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user