brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 1644b0a Raw
188 lines · plain
1// RUN: llvm-tblgen %s | FileCheck %s2// RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s3// RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s4// RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s5// RUN: not llvm-tblgen -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s6// RUN: not llvm-tblgen -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s7// RUN: not llvm-tblgen -DERROR6 %s 2>&1 | FileCheck --check-prefix=ERROR6 %s8// RUN: not llvm-tblgen -DERROR7 %s 2>&1 | FileCheck --check-prefix=ERROR7 %s9// RUN: not llvm-tblgen -DERROR8 %s 2>&1 | FileCheck --check-prefix=ERROR8 %s10// RUN: not llvm-tblgen -DERROR9 %s 2>&1 | FileCheck --check-prefix=ERROR9 %s11// RUN: not llvm-tblgen -DERROR10 %s 2>&1 | FileCheck --check-prefix=ERROR10 %s12// RUN: not llvm-tblgen -DERROR11 %s 2>&1 | FileCheck --check-prefix=ERROR11 %s13 14// This file tests that all required arguments are specified and template15// arguments are type-checked and cast if necessary.16 17// Class template arguments.18 19class Class1<string nm> {20  string Name = nm;21}22 23// CHECK: def Rec124// CHECK:   string Name = "Alice"25// CHECK:   string NameName = "AliceAlice"26 27def Rec1 : Class1<"Alice"> {28  string NameName = Name # Name;29}30 31#ifdef ERROR132// ERROR1: Value specified for template argument 'Class1:nm' is of type int33 34def Rec2 : Class1<42> {35}36#endif37 38class Class2<bits<8> cd> {39  int Code = cd;40}41 42// CHECK: def Rec343// CHECK:   int Code = 4244// CHECK:   list<int> CodeList = [42]45 46def Rec3 : Class2<0b00101010> {47  list<int> CodeList = [Code];48}49 50// CHECK: def Rec451// CHECK:   int Code = 4252// CHECK:   list<int> CodeList = [42]53 54def Rec4 : Class2<42> {55  list<int> CodeList = [Code];56}57 58#ifdef ERROR259// ERROR2: Value specified for template argument 'Class2:cd' is of type string60 61def Rec5 : Class2<"oops"> {62  list<int> CodeList = [Code];63}64#endif65 66// Anonymous class instantiation template arguments.67 68// CHECK: def Rec669// CHECK:   string Name = "Ted"70 71def Rec6 {72  string Name = Class1<"Ted">.Name;73}74 75#ifdef ERROR376// ERROR3: Value specified for template argument 'Class1:nm' is of type int77 78def Rec7 {79  string Name = Class1<42>.Name;80}81#endif82 83// CHECK: def Rec884// CHECK:   list<int> CodeList = [42]85 86def Rec8 {87  list<int> CodeList = [Class2<42>.Code];88}89 90#ifdef ERROR491// ERROR4: Value specified for template argument 'Class2:cd' is of type string92 93def Rec9 {94  list<int> CodeList = [Class2<"huh?">.Code];95}96#endif97 98// Multiclass template arguments.99 100multiclass MC1<string nm> {101  def _1 {102    string Name = nm;103  }104  def _2 {105    string NameNmae = nm # nm;106  }107}108 109// CHECK: def RecMC1_1110// CHECK:   string Name = "Carol"111// CHECK: def RecMC1_2112// CHECK:   string NameNmae = "CarolCarol"113 114defm RecMC1 : MC1<"Carol">;115 116#ifdef ERROR5117// ERROR5: Value specified for template argument 'MC1::nm' is of type int118 119defm RecMC2 : MC1<42>;120#endif121 122multiclass MC2<bits<8> cd> {123  def _1 {124    bits<8> Code = cd;125  }126  def _2 {127    int Code = cd;128  }129  def _3 {130    list<int> CodeList = [cd];131  }132}133 134// CHECK: def RecMC3_1135// CHECK:   bits<8> Code = { 0, 0, 1, 0, 1, 0, 1, 0 }136// CHECK: def RecMC3_2137// CHECK:   int Code = 42138// CHECK: def RecMC3_3139// CHECK:   list<int> CodeList = [42]140 141defm RecMC3 : MC2<42>;142 143#ifdef ERROR6144// ERROR6: Value specified for template argument 'MC2::cd' is of type string145 146defm RecMC4 : MC2<"Bob">;147#endif148 149#ifdef ERROR7150multiclass TwoArgs<bits<8> a, string b> {151  def _1 { bits<8> A = a; }152  def _2 { string B = b; }153}154defm Good : TwoArgs<1, "one">;155defm MissingComma : TwoArgs<2 "two">;156// ERROR7: [[#@LINE-1]]:31: error: Expected comma before next argument157#endif158 159#ifdef ERROR8160def error8: Class1;161// ERROR8: value not specified for template argument 'Class1:nm'162// ERROR8: 19:21: note: declared in 'Class1'163#endif164 165#ifdef ERROR9166defm error9: MC1;167// ERROR9: value not specified for template argument 'MC1::nm'168// ERROR9: 100:23: note: declared in 'MC1'169#endif170 171#ifdef ERROR10172def error10 {173  int value = Class2<>.Code;174}175// ERROR10: value not specified for template argument 'Class2:cd'176// ERROR10: 38:22: note: declared in 'Class2'177#endif178 179#ifdef ERROR11180 181class Foo<int i, int j>;182 183def error11 : Foo<"", "">;184// ERROR11: [[#@LINE-1]]:19: error: Value specified for template argument 'Foo:i' is of type string; expected type int: ""185// ERROR11: [[#@LINE-2]]:23: error: Value specified for template argument 'Foo:j' is of type string; expected type int: ""186 187#endif188