mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add builtins for basic float operations (#3897)
Adds support for unary `-` and binary `+`, `-`, `*`, `/` for floating point types. Real literals are now transformed to `llvm::APFloat`s during the check phase into the `FloatLiteral` instruction. This PR likely collides a bit with #3892 and might need to be updated when that one is merged.
This commit is contained in:
@@ -19,7 +19,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- fail_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %.1: f64 = real_literal 10e-1 [template]
|
||||
// CHECK:STDOUT: %.1: f64 = float_literal 1 [template]
|
||||
// CHECK:STDOUT: %.2: type = tuple_type () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -45,7 +45,7 @@ fn F() {
|
||||
// CHECK:STDOUT: fn @F() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %G.ref: <function> = name_ref G, file.%G [template = file.%G]
|
||||
// CHECK:STDOUT: %.loc16: f64 = real_literal 10e-1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc16: f64 = float_literal 1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %G.call: init () = call %G.ref(<invalid>) [template = <error>]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -16,7 +16,7 @@ fn Run() {
|
||||
// CHECK:STDOUT: --- fail_return_type_mismatch.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %.1: f64 = real_literal 10e-1 [template]
|
||||
// CHECK:STDOUT: %.1: f64 = float_literal 1 [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
@@ -34,7 +34,7 @@ fn Run() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @Foo() -> f64 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %.loc7: f64 = real_literal 10e-1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc7: f64 = float_literal 1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: return %.loc7
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user