Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions llvm/lib/TableGen/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2094,10 +2094,12 @@ const Init *IsAOpInit::Fold() const {
return IntInit::get(getRecordKeeper(), 1);

if (isa<RecordRecTy>(CheckType)) {
// If the target type is not a subclass of the expression type, or if
// the expression has fully resolved to a record, we know that it can't
// be of the required type.
if (!CheckType->typeIsConvertibleTo(TI->getType()) || isa<DefInit>(Expr))
// If the target type is not a subclass of the expression type once the
// expression has been made concrete, or if the expression has fully
// resolved to a record, we know that it can't be of the required type.
if ((!CheckType->typeIsConvertibleTo(TI->getType()) &&
Expr->isConcrete()) ||
isa<DefInit>(Expr))
return IntInit::get(getRecordKeeper(), 0);
} else {
// We treat non-record types as not castable.
Expand Down
33 changes: 33 additions & 0 deletions llvm/test/TableGen/isa-non-primary.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// RUN: llvm-tblgen %s | FileCheck %s

// CHECK: --- Defs ---
// CHECK: def Op1 { // Op
// CHECK-NEXT: string res = "yes";
// CHECK-NEXT: }
// CHECK: def Op2 { // Op
// CHECK-NEXT: string res = "no";
// CHECK-NEXT: }

class A<int a> {
int x = a;
}

class B<int a> : A<a> {
bit y = 0;
}

class C<int a> {
int z = !add(a, 16);
}

class D<int a> : B<a>, C<a>;

def E1 : D<5>;
def E2 : B<2>;

class Op<A value> {
string res = !if(!isa<C>(value), "yes", "no");
}

def Op1 : Op<E1>;
def Op2 : Op<E2>;