1 // RUN: mlir-opt %s -split-input-file -verify-diagnostics| FileCheck %s
3 // CHECK-LABEL: @test_enum_attr_roundtrip
4 func.func @test_enum_attr_roundtrip() -> () {
5 // CHECK: attr = #test.custom_float<"float" : 2.000000e+00>
6 "test.op"() {attr = #test.custom_float<"float" : 2.>} : () -> ()
7 // CHECK: attr = #test.custom_float<"double" : 2.000000e+00>
8 "test.op"() {attr = #test.custom_float<"double" : 2.>} : () -> ()
9 // CHECK: attr = #test.custom_float<"fp80" : 2.000000e+00>
10 "test.op"() {attr = #test.custom_float<"fp80" : 2.>} : () -> ()
11 // CHECK: attr = #test.custom_float<"float" : 0x7FC00000>
12 "test.op"() {attr = #test.custom_float<"float" : 0x7FC00000>} : () -> ()
13 // CHECK: attr = #test.custom_float<"double" : 0x7FF0000001000000>
14 "test.op"() {attr = #test.custom_float<"double" : 0x7FF0000001000000>} : () -> ()
15 // CHECK: attr = #test.custom_float<"fp80" : 0x7FFFC000000000100000>
16 "test.op"() {attr = #test.custom_float<"fp80" : 0x7FFFC000000000100000>} : () -> ()
22 // Verify literal must be hex or float
24 // expected-error @below {{unexpected decimal integer literal for a floating point value}}
25 // expected-note @below {{add a trailing dot to make the literal a float}}
26 "test.op"() {attr = #test.custom_float<"float" : 42>} : () -> ()
30 // Integer value must be in the width of the floating point type
32 // expected-error @below {{hexadecimal float constant out of range for type}}
33 "test.op"() {attr = #test.custom_float<"float" : 0x7FC000000>} : () -> ()
38 // Integer value must be in the width of the floating point type
40 // expected-error @below {{hexadecimal float constant out of range for type}}
41 "test.op"() {attr = #test.custom_float<"double" : 0x7FC000007FC0000000>} : () -> ()
46 // Integer value must be in the width of the floating point type
48 // expected-error @below {{hexadecimal float constant out of range for type}}
49 "test.op"() {attr = #test.custom_float<"fp80" : 0x7FC0000007FC0000007FC000000>} : () -> ()
53 // Value must be a floating point literal or integer literal
55 // expected-error @below {{expected floating point literal}}
56 "test.op"() {attr = #test.custom_float<"float" : "blabla">} : () -> ()