[PATCH] D86631: [Fixed Point] Add fixed-point to floating point cast types and consteval.
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG9fa7f4845976: [Fixed Point] Add fixed-point to floating point cast types and consteval. (authored by ebevhan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86631/new/ https://reviews.llvm.org/D86631 Files: clang/include/clang/AST/OperationKinds.def clang/lib/AST/Expr.cpp clang/lib/AST/ExprConstant.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CGExprComplex.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/Edit/RewriteObjCFoundationAPI.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp clang/test/Frontend/fixed_point_conversions_const.c clang/test/Frontend/fixed_point_errors.c clang/test/Frontend/fixed_point_unknown_conversions.c Index: clang/test/Frontend/fixed_point_unknown_conversions.c === --- clang/test/Frontend/fixed_point_unknown_conversions.c +++ clang/test/Frontend/fixed_point_unknown_conversions.c @@ -22,16 +22,12 @@ _Fract fract = accum; // ok _Accum *accum_ptr; - accum = f; // expected-error{{conversion between fixed point and 'float' is not yet supported}} - accum = d; // expected-error{{conversion between fixed point and 'double' is not yet supported}} accum = dc; // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}} accum = ic; // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}} accum = s; // expected-error{{assigning to '_Accum' from incompatible type 'struct S'}} accum = ptr; // expected-error{{assigning to '_Accum' from incompatible type 'int *'}} accum_ptr = ptr; // expected-warning{{incompatible pointer types assigning to '_Accum *' from 'int *'}} - f = accum; // expected-error{{conversion between fixed point and 'float' is not yet supported}} - d = accum; // expected-error{{conversion between fixed point and 'double' is not yet supported}} dc = accum; // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}} ic = accum; // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}} s = accum; // expected-error{{assigning to 'struct S' from incompatible type '_Accum'}} Index: clang/test/Frontend/fixed_point_errors.c === --- clang/test/Frontend/fixed_point_errors.c +++ clang/test/Frontend/fixed_point_errors.c @@ -286,8 +286,3 @@ // Division by zero short _Accum div_zero = 4.5k / 0.0lr; // expected-error {{initializer element is not a compile-time constant}} - -void foo(void) { - _Accum x = 0.5k; - if (x == 0.5) {} // expected-error{{invalid operands to binary expression ('_Accum' and 'double')}} -} Index: clang/test/Frontend/fixed_point_conversions_const.c === --- clang/test/Frontend/fixed_point_conversions_const.c +++ clang/test/Frontend/fixed_point_conversions_const.c @@ -43,6 +43,37 @@ short _Accum sa_const7 = -256; // CHECK-DAG: @sa_const7 = {{.*}}global i16 -32768, align 2 +// Fixed point to floating point +float fl_const = 1.0hk; +// CHECK-DAG: @fl_const = {{.*}}global float 1.00e+00, align 4 +float fl_const2 = -128.0k; +// CHECK-DAG: @fl_const2 = {{.*}}global float -1.28e+02, align 4 +float fl_const3 = 0.0872802734375k; +// CHECK-DAG: @fl_const3 = {{.*}}global float 0x3FB65800, align 4 +float fl_const4 = 192.5k; +// CHECK-DAG: @fl_const4 = {{.*}}global float 1.925000e+02, align 4 +float fl_const5 = -192.5k; +// CHECK-DAG: @fl_const5 = {{.*}}global float -1.925000e+02, align 4 + +// Floating point to fixed point +_Accum a_fl_const = 1.0f; +// CHECK-DAG: @a_fl_const = {{.*}}global i32 32768, align 4 +_Accum a_fl_const2 = -128.0f; +// CHECK-DAG: @a_fl_const2 = {{.*}}global i32 -4194304, align 4 +_Accum a_fl_const3 = 0.0872802734375f; +// CHECK-DAG: @a_fl_const3 = {{.*}}global i32 2860, align 4 +_Accum a_fl_const4 = 0.0872802734375; +// CHECK-DAG: @a_fl_const4 = {{.*}}global i32 2860, align 4 +_Accum a_fl_const5 = -0.0872802734375f; +// CHECK-DAG: @a_fl_const5 = {{.*}}global i32 -2860, align 4 +_Fract f_fl_const = 0.5f; +// CHECK-DAG: @f_fl_const = {{.*}}global i16 16384, align 2 +_Fract f_fl_const2 = -0.75; +// CHECK-DAG: @f_fl_const2 = {{.*}}global i16 -24576, align 2 +unsigned short _Accum usa_fl_const = 48.75f; +// SIGNED-DAG: @usa_fl_const = {{.*}}global i16 12480, align 2 +// UNSIGNED-DAG: @usa_fl_const = {{.*}}global i16 6240, align 2 + // Signedness unsigned short _Accum usa_const2 = 2.5hk; // SIGNED-DAG: @usa_const2 = {{.*}}global i16 640, align 2 Index: clang/lib/StaticAnalyzer/Core/ExprEngine
[PATCH] D86631: [Fixed Point] Add fixed-point to floating point cast types and consteval.
ebevhan updated this revision to Diff 290266. ebevhan added a comment. Rebased. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86631/new/ https://reviews.llvm.org/D86631 Files: clang/include/clang/AST/OperationKinds.def clang/lib/AST/Expr.cpp clang/lib/AST/ExprConstant.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CGExprComplex.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/Edit/RewriteObjCFoundationAPI.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp clang/test/Frontend/fixed_point_conversions_const.c clang/test/Frontend/fixed_point_errors.c clang/test/Frontend/fixed_point_unknown_conversions.c Index: clang/test/Frontend/fixed_point_unknown_conversions.c === --- clang/test/Frontend/fixed_point_unknown_conversions.c +++ clang/test/Frontend/fixed_point_unknown_conversions.c @@ -22,16 +22,12 @@ _Fract fract = accum; // ok _Accum *accum_ptr; - accum = f; // expected-error{{conversion between fixed point and 'float' is not yet supported}} - accum = d; // expected-error{{conversion between fixed point and 'double' is not yet supported}} accum = dc; // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}} accum = ic; // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}} accum = s; // expected-error{{assigning to '_Accum' from incompatible type 'struct S'}} accum = ptr; // expected-error{{assigning to '_Accum' from incompatible type 'int *'}} accum_ptr = ptr; // expected-warning{{incompatible pointer types assigning to '_Accum *' from 'int *'}} - f = accum; // expected-error{{conversion between fixed point and 'float' is not yet supported}} - d = accum; // expected-error{{conversion between fixed point and 'double' is not yet supported}} dc = accum; // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}} ic = accum; // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}} s = accum; // expected-error{{assigning to 'struct S' from incompatible type '_Accum'}} Index: clang/test/Frontend/fixed_point_errors.c === --- clang/test/Frontend/fixed_point_errors.c +++ clang/test/Frontend/fixed_point_errors.c @@ -286,8 +286,3 @@ // Division by zero short _Accum div_zero = 4.5k / 0.0lr; // expected-error {{initializer element is not a compile-time constant}} - -void foo(void) { - _Accum x = 0.5k; - if (x == 0.5) {} // expected-error{{invalid operands to binary expression ('_Accum' and 'double')}} -} Index: clang/test/Frontend/fixed_point_conversions_const.c === --- clang/test/Frontend/fixed_point_conversions_const.c +++ clang/test/Frontend/fixed_point_conversions_const.c @@ -43,6 +43,37 @@ short _Accum sa_const7 = -256; // CHECK-DAG: @sa_const7 = {{.*}}global i16 -32768, align 2 +// Fixed point to floating point +float fl_const = 1.0hk; +// CHECK-DAG: @fl_const = {{.*}}global float 1.00e+00, align 4 +float fl_const2 = -128.0k; +// CHECK-DAG: @fl_const2 = {{.*}}global float -1.28e+02, align 4 +float fl_const3 = 0.0872802734375k; +// CHECK-DAG: @fl_const3 = {{.*}}global float 0x3FB65800, align 4 +float fl_const4 = 192.5k; +// CHECK-DAG: @fl_const4 = {{.*}}global float 1.925000e+02, align 4 +float fl_const5 = -192.5k; +// CHECK-DAG: @fl_const5 = {{.*}}global float -1.925000e+02, align 4 + +// Floating point to fixed point +_Accum a_fl_const = 1.0f; +// CHECK-DAG: @a_fl_const = {{.*}}global i32 32768, align 4 +_Accum a_fl_const2 = -128.0f; +// CHECK-DAG: @a_fl_const2 = {{.*}}global i32 -4194304, align 4 +_Accum a_fl_const3 = 0.0872802734375f; +// CHECK-DAG: @a_fl_const3 = {{.*}}global i32 2860, align 4 +_Accum a_fl_const4 = 0.0872802734375; +// CHECK-DAG: @a_fl_const4 = {{.*}}global i32 2860, align 4 +_Accum a_fl_const5 = -0.0872802734375f; +// CHECK-DAG: @a_fl_const5 = {{.*}}global i32 -2860, align 4 +_Fract f_fl_const = 0.5f; +// CHECK-DAG: @f_fl_const = {{.*}}global i16 16384, align 2 +_Fract f_fl_const2 = -0.75; +// CHECK-DAG: @f_fl_const2 = {{.*}}global i16 -24576, align 2 +unsigned short _Accum usa_fl_const = 48.75f; +// SIGNED-DAG: @usa_fl_const = {{.*}}global i16 12480, align 2 +// UNSIGNED-DAG: @usa_fl_const = {{.*}}global i16 6240, align 2 + // Signedness unsigned short _Accum usa_const2 = 2.5hk; // SIGNED-DAG: @usa_const2 = {{.*}}global i16 640, align 2 Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp === --- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -4
[PATCH] D86631: [Fixed Point] Add fixed-point to floating point cast types and consteval.
ebevhan created this revision. ebevhan added reviewers: leonardchan, rjmccall. Herald added subscribers: bjope, martong. Herald added a project: clang. ebevhan requested review of this revision. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D86631 Files: clang/include/clang/AST/OperationKinds.def clang/lib/AST/Expr.cpp clang/lib/AST/ExprConstant.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CGExprComplex.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/Edit/RewriteObjCFoundationAPI.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp clang/test/Frontend/fixed_point_conversions_const.c clang/test/Frontend/fixed_point_errors.c clang/test/Frontend/fixed_point_unknown_conversions.c Index: clang/test/Frontend/fixed_point_unknown_conversions.c === --- clang/test/Frontend/fixed_point_unknown_conversions.c +++ clang/test/Frontend/fixed_point_unknown_conversions.c @@ -22,16 +22,12 @@ _Fract fract = accum; // ok _Accum *accum_ptr; - accum = f; // expected-error{{conversion between fixed point and 'float' is not yet supported}} - accum = d; // expected-error{{conversion between fixed point and 'double' is not yet supported}} accum = dc; // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}} accum = ic; // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}} accum = s; // expected-error{{assigning to '_Accum' from incompatible type 'struct S'}} accum = ptr; // expected-error{{assigning to '_Accum' from incompatible type 'int *'}} accum_ptr = ptr; // expected-warning{{incompatible pointer types assigning to '_Accum *' from 'int *'}} - f = accum; // expected-error{{conversion between fixed point and 'float' is not yet supported}} - d = accum; // expected-error{{conversion between fixed point and 'double' is not yet supported}} dc = accum; // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}} ic = accum; // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}} s = accum; // expected-error{{assigning to 'struct S' from incompatible type '_Accum'}} Index: clang/test/Frontend/fixed_point_errors.c === --- clang/test/Frontend/fixed_point_errors.c +++ clang/test/Frontend/fixed_point_errors.c @@ -286,8 +286,3 @@ // Division by zero short _Accum div_zero = 4.5k / 0.0lr; // expected-error {{initializer element is not a compile-time constant}} - -void foo(void) { - _Accum x = 0.5k; - if (x == 0.5) {} // expected-error{{invalid operands to binary expression ('_Accum' and 'double')}} -} Index: clang/test/Frontend/fixed_point_conversions_const.c === --- clang/test/Frontend/fixed_point_conversions_const.c +++ clang/test/Frontend/fixed_point_conversions_const.c @@ -43,6 +43,37 @@ short _Accum sa_const7 = -256; // CHECK-DAG: @sa_const7 = {{.*}}global i16 -32768, align 2 +// Fixed point to floating point +float fl_const = 1.0hk; +// CHECK-DAG: @fl_const = {{.*}}global float 1.00e+00, align 4 +float fl_const2 = -128.0k; +// CHECK-DAG: @fl_const2 = {{.*}}global float -1.28e+02, align 4 +float fl_const3 = 0.0872802734375k; +// CHECK-DAG: @fl_const3 = {{.*}}global float 0x3FB65800, align 4 +float fl_const4 = 192.5k; +// CHECK-DAG: @fl_const4 = {{.*}}global float 1.925000e+02, align 4 +float fl_const5 = -192.5k; +// CHECK-DAG: @fl_const5 = {{.*}}global float -1.925000e+02, align 4 + +// Floating point to fixed point +_Accum a_fl_const = 1.0f; +// CHECK-DAG: @a_fl_const = {{.*}}global i32 32768, align 4 +_Accum a_fl_const2 = -128.0f; +// CHECK-DAG: @a_fl_const2 = {{.*}}global i32 -4194304, align 4 +_Accum a_fl_const3 = 0.0872802734375f; +// CHECK-DAG: @a_fl_const3 = {{.*}}global i32 2860, align 4 +_Accum a_fl_const4 = 0.0872802734375; +// CHECK-DAG: @a_fl_const4 = {{.*}}global i32 2860, align 4 +_Accum a_fl_const5 = -0.0872802734375f; +// CHECK-DAG: @a_fl_const5 = {{.*}}global i32 -2860, align 4 +_Fract f_fl_const = 0.5f; +// CHECK-DAG: @f_fl_const = {{.*}}global i16 16384, align 2 +_Fract f_fl_const2 = -0.75; +// CHECK-DAG: @f_fl_const2 = {{.*}}global i16 -24576, align 2 +unsigned short _Accum usa_fl_const = 48.75f; +// SIGNED-DAG: @usa_fl_const = {{.*}}global i16 12480, align 2 +// UNSIGNED-DAG: @usa_fl_const = {{.*}}global i16 6240, align 2 + // Signedness unsigned short _Accum usa_const2 = 2.5hk; // SIGNED-DAG: @usa_const2 = {{.*}}global i16 640, align 2 Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp === --- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ clan