2018-03-05 15:01:38 +01:00
|
|
|
// RUN: not llvm-tblgen %s 2>&1 | FileCheck %s
|
|
|
|
// XFAIL: vg_leak
|
|
|
|
|
|
|
|
// This test verifies that tablegen does fail if it can't resolve an unresolved
|
|
|
|
// !cast() during processing top-level defm.
|
|
|
|
|
|
|
|
class A {}
|
|
|
|
class B<A a> {
|
|
|
|
A ba = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
multiclass M0<string s> {
|
|
|
|
// This should work fine.
|
|
|
|
def _m00 : B<!cast<A>(s)>;
|
2018-03-19 15:13:37 +01:00
|
|
|
// CHECK: error: Undefined reference to record: 'd1_r1_no_such_record'
|
2018-03-05 15:01:38 +01:00
|
|
|
def _m01: B<!cast<A>(s#"_no_such_record")>;
|
|
|
|
}
|
|
|
|
|
|
|
|
multiclass M1<string s> {
|
|
|
|
def _r1 : A;
|
|
|
|
// It would be nice if we could refer to _r1's name without having to pass it
|
|
|
|
// explicitly via 's'.
|
|
|
|
// XCHECK-DAG: note: instantiated from multiclass
|
|
|
|
defm _m1: M0<s # "_r1">;
|
|
|
|
}
|
|
|
|
|
TableGen: Streamline how defs are instantiated
Summary:
Instantiating def's and defm's needs to perform the following steps:
- for defm's, clone multiclass def prototypes and subsitute template args
- for def's and defm's, add subclass definitions, substituting template
args
- clone the record based on foreach loops and substitute loop iteration
variables
- override record variables based on the global 'let' stack
- resolve the record name (this should be simple, but unfortunately it's
not due to existing .td files relying on rather silly implementation
details)
- for def(m)s in multiclasses, add the unresolved record as a multiclass
prototype
- for top-level def(m)s, resolve all internal variable references and add
them to the record keeper and any active defsets
This change streamlines how we go through these steps, by having both
def's and defm's feed into a single addDef() method that handles foreach,
final resolve, and routing the record to the right place.
This happens to make foreach inside of multiclasses work, as the new
test case demonstrates. Previously, foreach inside multiclasses was not
forbidden by the parser, but it was de facto broken.
Another side effect is that the order of "instantiated from" notes in error
messages is reversed, as the modified test case shows. This is arguably
clearer, since the initial error message ends up pointing directly to
whatever triggered the error, and subsequent notes will point to increasingly
outer layers of multiclasses. This is consistent with how C++ compilers
report nested #includes and nested template instantiations.
Change-Id: Ica146d0db2bc133dd7ed88054371becf24320447
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D44478
llvm-svn: 328117
2018-03-21 18:12:53 +01:00
|
|
|
// CHECK: def _m01: B
|
2018-03-05 15:01:38 +01:00
|
|
|
// CHECK: note: instantiated from multiclass
|
|
|
|
// CHECK: defm _m1: M0
|
|
|
|
// CHECK: note: instantiated from multiclass
|
TableGen: Streamline how defs are instantiated
Summary:
Instantiating def's and defm's needs to perform the following steps:
- for defm's, clone multiclass def prototypes and subsitute template args
- for def's and defm's, add subclass definitions, substituting template
args
- clone the record based on foreach loops and substitute loop iteration
variables
- override record variables based on the global 'let' stack
- resolve the record name (this should be simple, but unfortunately it's
not due to existing .td files relying on rather silly implementation
details)
- for def(m)s in multiclasses, add the unresolved record as a multiclass
prototype
- for top-level def(m)s, resolve all internal variable references and add
them to the record keeper and any active defsets
This change streamlines how we go through these steps, by having both
def's and defm's feed into a single addDef() method that handles foreach,
final resolve, and routing the record to the right place.
This happens to make foreach inside of multiclasses work, as the new
test case demonstrates. Previously, foreach inside multiclasses was not
forbidden by the parser, but it was de facto broken.
Another side effect is that the order of "instantiated from" notes in error
messages is reversed, as the modified test case shows. This is arguably
clearer, since the initial error message ends up pointing directly to
whatever triggered the error, and subsequent notes will point to increasingly
outer layers of multiclasses. This is consistent with how C++ compilers
report nested #includes and nested template instantiations.
Change-Id: Ica146d0db2bc133dd7ed88054371becf24320447
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D44478
llvm-svn: 328117
2018-03-21 18:12:53 +01:00
|
|
|
// CHECK: defm d1: M1
|
2018-03-05 15:01:38 +01:00
|
|
|
defm d1: M1<"d1">;
|