Index: llvm/trunk/lib/TableGen/Record.cpp =================================================================== --- llvm/trunk/lib/TableGen/Record.cpp +++ llvm/trunk/lib/TableGen/Record.cpp @@ -1887,7 +1887,7 @@ PrintFatalError(getLoc(), Twine("Invalid value ") + Type + "is found when setting '" + Value.getNameInitAsString() + - " of type '" + + "' of type '" + Value.getType()->getAsString() + "' after resolving references: " + VR->getAsUnquotedString() + "\n"); Index: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td =================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td @@ -4695,10 +4695,10 @@ def DWSwapInByte { dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1), (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1)); - dag Swap2 = (OR8 (AND8 (RLDICL DWSwapInByte.Swap1, 62, 2), DWMaskValues.Lo2), - (AND8 (RLDICR DWSwapInByte.Swap1, 2, 61), DWMaskValues.Hi2)); - dag Swap4 = (OR8 (AND8 (RLDICL DWSwapInByte.Swap2, 60, 4), DWMaskValues.Lo4), - (AND8 (RLDICR DWSwapInByte.Swap2, 4, 59), DWMaskValues.Hi4)); + dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2), + (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2)); + dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4), + (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4)); } // Intra-byte swap is done, now start inter-byte swap. @@ -4718,7 +4718,7 @@ def DWBytes7654 { dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31); dag DWord = - (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), DWBytes7654.Word, sub_32)); + (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32)); } def DWBytes0123 { @@ -4737,7 +4737,7 @@ def DWBytes3210 { dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31); dag DWord = - (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), DWBytes3210.Word, sub_32)); + (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32)); } // Now both high word and low word are reversed, next Index: llvm/trunk/test/TableGen/cast-typeerror.td =================================================================== --- llvm/trunk/test/TableGen/cast-typeerror.td +++ llvm/trunk/test/TableGen/cast-typeerror.td @@ -0,0 +1,14 @@ +// RUN: not llvm-tblgen %s 2>&1 | FileCheck %s +// XFAIL: vg_leak + +class A; +class B; + +def A0 : A; + +class C { + B b = !cast(name); +} + +// CHECK: error: Invalid value of type 'A' is found when setting 'b' of type 'B' +def Test : C<"A0">; Index: llvm/trunk/test/TableGen/self-reference-typeerror.td =================================================================== --- llvm/trunk/test/TableGen/self-reference-typeerror.td +++ llvm/trunk/test/TableGen/self-reference-typeerror.td @@ -0,0 +1,13 @@ +// RUN: not llvm-tblgen %s 2>&1 | FileCheck %s +// XFAIL: vg_leak + +class A { + A a = x; +} + +// At the time A0 is referenced, A has not yet been established as a superclass. +// This kind of self-reference is discourage, but if you *really* want it, you +// can force it with !cast. +// +// CHECK: Value 'A:x' of type 'A' is incompatible with initializer +def A0 : A; Index: llvm/trunk/test/TableGen/self-reference.td =================================================================== --- llvm/trunk/test/TableGen/self-reference.td +++ llvm/trunk/test/TableGen/self-reference.td @@ -0,0 +1,44 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +// CHECK: --- Defs --- + +// CHECK: def A0 { +// CHECK: dag a = (ops A0); +// CHECK: } + +// CHECK: def B0 { +// CHECK: dag a = (ops); +// CHECK: A b = B0; +// CHECK: } + +// CHECK: def C0 { +// CHECK: dag q = (ops C0); +// CHECK: } + +def ops; + +class A { + dag a = d; +} + +// This type of self-reference is used in various places defining register +// classes. +def A0 : A<(ops A0)>; + +class B { + A b = !cast(self); +} + +// A stronger form of this type of self-reference is used at least in the +// SystemZ backend to define a record which is a ComplexPattern and an Operand +// at the same time. +def B0 : A<(ops)>, B<"B0">; + +// Casting C0 to C by name here is tricky, because it happens while (or rather: +// before) adding C as a superclass. However, SystemZ uses this pattern. +class C { + dag q = (ops !cast(self)); +} + +def C0 : C<"C0">;