summaryrefslogtreecommitdiffstats
path: root/llvm/test/TableGen/name-resolution-consistency.td
blob: 25cd6cd68e28c45b97c90acb7b614f583e23975b (plain)
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
// RUN: llvm-tblgen %s | FileCheck %s
// XFAIL: vg_leak

// This test demonstrates a number of inconsistencies in how NAME is resolved
// and record names are constructed.
//
// The TODO lines describe a suggested consistent behavior that would result
// from:
//  (1) Treating NAME as an implicit multiclass template argument and
//  (2) always storing the name of (non-anonymous) prototype records in
//      multiclasses with at least one explicit reference to NAME.
//
// Unfortunately, several backends (including X86) rely quite heavily on the
// current inconsistent behavior and would have to be fixed.

// CHECK: def B0a {
// CHECK:   string e = "B0";
// CHECK: }

// CHECK: def B0ba {
// TODO: expect "B0b" here
// CHECK:   string a = "B0";
// CHECK:   string b = "B0";
// CHECK: }

// CHECK: def B0cza {
// TODO: expect "B0cz" here
// CHECK:   string a = "B0";
// CHECK:   string b = "B0";
// CHECK: }

// TODO: expect this to be named 'xB0b'
// CHECK: def B0xb {
// TODO: expect "B0b" here
// CHECK:   string c = "b";
// CHECK:   string d = "b";
// CHECK: }

// TODO: expect this to be named B0bys
// CHECK: def B0ys {
// TODO: expect "B0b" here
// CHECK:   string f = "b";
// CHECK:   string g = "b";
// CHECK: }

// CHECK: def xB0cz {
// CHECK:   string c = "B0cz";
// CHECK:   string d = "B0cz";
// CHECK: }

// TODO: expect this to be named B0czyt
// CHECK: def yt {
// CHECK:   string f = "B0cz";
// CHECK:   string g = "B0cz";
// CHECK: }

multiclass A<string p, string q> {
  def a {
    string a = NAME;
    string b = p;
  }

  def x # NAME {
    string c = NAME;
    string d = p;
  }

  def y # q {
    string f = NAME;
    string g = p;
  }
}

multiclass B<string name, string t> {
  def a {
    string e = NAME;
  }

  defm b : A<NAME, "s">;

  defm NAME # c # name : A<NAME, t>;
}

defm B0 : B<"z", "t">;
OpenPOWER on IntegriCloud