File: convert-to-llvm-invalid.fir

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (107 lines) | stat: -rw-r--r-- 3,803 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Test FIR to LLVM IR conversion invalid cases and diagnostics.

// RUN: fir-opt --split-input-file --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" --verify-diagnostics %s

// Test `fir.zero` conversion failure with aggregate type.
// Not implemented yet.

func.func @zero_aggregate() {
  // expected-error@+1{{failed to legalize operation 'fir.zero_bits'}}
  %a = fir.zero_bits !fir.array<10xf32>
  return
}

// -----

// Verify that `fir.dt_entry` requires a parent op

// expected-error@+1{{'fir.dt_entry' op expects parent op 'fir.dispatch_table'}}
fir.dt_entry "method", @method_impl

// -----

// Test `fir.shape` conversion failure because the op has uses.

func.func @shape_not_dead(%arg0: !fir.ref<!fir.array<?x?xf32>>, %i: index, %j: index) {
  %c0 = arith.constant 1 : index
  // expected-error@+1{{failed to legalize operation 'fir.shape'}}
  %0 = fir.shape %c0, %c0 : (index, index) -> !fir.shape<2>
  %1 = fir.array_coor %arg0(%0) %i, %j : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>, index, index) -> !fir.ref<f32>
  return
}

// -----

// Test `fir.slice` conversion failure because the op has uses.

func.func @slice_not_dead(%arg0: !fir.ref<!fir.array<?x?xf32>>, %i: index, %j: index) {
  %c0 = arith.constant 1 : index
  // expected-error@+1{{failed to legalize operation 'fir.slice'}}
  %0 = fir.slice %c0, %c0, %c0, %c0, %c0, %c0 : (index, index, index, index, index, index) -> !fir.slice<2>
  %1 = fir.array_coor %arg0[%0] %i, %j : (!fir.ref<!fir.array<?x?xf32>>, !fir.slice<2>, index, index) -> !fir.ref<f32>
  return
}

// -----

// Test `fir.shift` conversion failure because the op has uses.

func.func @shift_not_dead(%arg0: !fir.box<!fir.array<?xf32>>, %i: index) {
  %c0 = arith.constant 1 : index
  // expected-error@+1{{failed to legalize operation 'fir.shift'}}
  %0 = fir.shift %c0 : (index) -> !fir.shift<1>
  %1 = fir.array_coor %arg0(%0) %i : (!fir.box<!fir.array<?xf32>>, !fir.shift<1>, index) -> !fir.ref<f32>
  return
}

// -----

// Test `fir.shape_shift` conversion failure because the op has uses.

func.func @shape_shift_not_dead(%arg0: !fir.ref<!fir.array<?x?xf32>>, %i: index, %j: index) {
  %c0 = arith.constant 1 : index
  // expected-error@+1{{failed to legalize operation 'fir.shape_shift'}}
  %0 = fir.shape_shift %c0, %c0, %c0, %c0 : (index, index, index, index) -> !fir.shapeshift<2>
  %1 = fir.array_coor %arg0(%0) %i, %j : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>, index, index) -> !fir.ref<f32>
  return
}

// -----

// Test `fir.select_type` conversion to llvm.
// Should have been converted.

func.func @bar_select_type(%arg : !fir.class<!fir.type<derivedst{a:f32}>>) -> i32 {
  %0 = arith.constant 1 : i32
  %2 = arith.constant 3 : i32
  // expected-error@+2{{fir.select_type should have already been converted}}
  // expected-error@+1{{failed to legalize operation 'fir.select_type'}}
  fir.select_type %arg : !fir.class<!fir.type<derivedst{a:f32}>> [
    #fir.type_is<!fir.int<4>>,^bb1(%0:i32),
    #fir.type_is<!fir.int<8>>,^bb2(%2:i32),
    unit,^bb5 ]
^bb1(%a : i32) :
  return %a : i32
^bb2(%b : i32) :
  return %b : i32
^bb5 :
  %zero = arith.constant 0 : i32
  return %zero : i32
}

// -----

// Verify that `fir.dt_entry` requires a parent op

// expected-error@+1{{'fir.dt_entry' op expects parent op 'fir.dispatch_table'}}
fir.dt_entry "method", @method_impl

// -----

// `fir.coordinate_of` - dynamically sized arrays are not supported
func.func @coordinate_of_dynamic_array(%arg0: !fir.ref<!fir.array<1x!fir.char<4,?>>>, %arg1: index) {
  // expected-error@+2{{fir.coordinate_of with a dynamic element size is unsupported}}
  // expected-error@+1{{failed to legalize operation 'fir.coordinate_of'}}
  %p = fir.coordinate_of %arg0, %arg1 : (!fir.ref<!fir.array<1x!fir.char<4,?>>>, index) -> !fir.ref<f32>
  return
}