mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:01:14 +01:00
Implement Core.Negate for float literals (#7616)
Addresses part of issue raised in #7159 by implementing float.negate builtin for FloatLiteralValues The following code now compiles: ``` let a: f64 = -1.0; ``` To achieve this I switch the mantissa from being unsigned to signed. Lexed literals within source file will still always be unsigned, however it is now possible to create negative FloatLiteralValue constants. Main non-local changes this causes is: - All llvm::APInt parsing / printing calls flipped isSigned param - Zero extension replaced with sign extension - getActiveBits() replaced with getSignificantBits() for min bit width calculation
This commit is contained in:
@@ -724,8 +724,8 @@ constexpr BuiltinInfo IntGreaterEq = {
|
||||
"int.greater_eq", ValidateSignature<auto(IntT, IntU)->Bool>};
|
||||
|
||||
// "float.negate": float negation.
|
||||
constexpr BuiltinInfo FloatNegate = {
|
||||
"float.negate", ValidateSignature<auto(SizedFloatT)->SizedFloatT>};
|
||||
constexpr BuiltinInfo FloatNegate = {"float.negate",
|
||||
ValidateSignature<auto(FloatT)->FloatT>};
|
||||
|
||||
// "float.add": float addition.
|
||||
constexpr BuiltinInfo FloatAdd = {
|
||||
|
||||
Reference in New Issue
Block a user