65 lines · plain
1// RUN: llvm-tblgen %s | FileCheck %s2// RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s3 4// This file contains tests for the !find bang operator.5 6defvar Sentence = "This is the end of the world.";7 8// CHECK: def Rec019// CHECK-NEXT: int FirstThe = 810// CHECK-NEXT: int SameThe = 811// CHECK-NEXT: int SecondThe = 1912// CHECK-NEXT: int ThirdThe = -113 14def Rec01 {15 int FirstThe = !find(Sentence, "the");16 int SameThe = !find(Sentence, "the", FirstThe);17 int SecondThe = !find(Sentence, "the", !add(FirstThe, 1));18 int ThirdThe = !find(Sentence, "the", !add(SecondThe, 1));19}20 21class C1<string name> {22 string Name = name;23 bit IsJr = !ne(!find(name, "Jr"), -1);24}25 26// CHECK: def Rec0227// CHECK-NEXT: string Name = "Sally Smith"28// CHECK-NEXT: bit IsJr = 029// CHECK: def Rec0330// CHECK-NEXT: string Name = "Fred Jones, Jr."31// CHECK-NEXT: bit IsJr = 132 33def Rec02 : C1<"Sally Smith">;34def Rec03 : C1<"Fred Jones, Jr.">;35 36// CHECK: def Rec0437// CHECK-NEXT: int ThisPos = 038// CHECK-NEXT: int WorldPos = 2339// CHECK-NEXT: int TooLong = -140 41def Rec04 {42 int ThisPos = !find(Sentence, "This");43 int WorldPos = !find(Sentence, "world.");44 int TooLong = !find(Sentence, "world.country");45}46 47// CHECK: def Rec0548// CHECK-NEXT: string Name = "Pat Snork"49// CHECK-NEXT: bit IsJr = 050// CHECK-NEXT: bit JrOrSnork = 151 52def Rec05 : C1<"Pat Snork"> {53 bit JrOrSnork = !or(IsJr, !ne(!find(Name, "Snork"), -1));54}55 56#ifdef ERROR157 58// ERROR1: !find start position is out of range 0...29: 10059 60def Rec06 {61 int Test1 = !find(Sentence, "the", 100);62}63#endif64 65