1 // RUN: llvm-tblgen %s | FileCheck %s
2 // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
4 // This file contains tests for the !find bang operator.
6 defvar Sentence = "This is the end of the world.";
9 // CHECK-NEXT: int FirstThe = 8
10 // CHECK-NEXT: int SameThe = 8
11 // CHECK-NEXT: int SecondThe = 19
12 // CHECK-NEXT: int ThirdThe = -1
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));
21 class C1<string name> {
23 bit IsJr = !ne(!find(name, "Jr"), -1);
27 // CHECK-NEXT: string Name = "Sally Smith"
28 // CHECK-NEXT: bit IsJr = 0
30 // CHECK-NEXT: string Name = "Fred Jones, Jr."
31 // CHECK-NEXT: bit IsJr = 1
33 def Rec02 : C1<"Sally Smith">;
34 def Rec03 : C1<"Fred Jones, Jr.">;
37 // CHECK-NEXT: int ThisPos = 0
38 // CHECK-NEXT: int WorldPos = 23
39 // CHECK-NEXT: int TooLong = -1
42 int ThisPos = !find(Sentence, "This");
43 int WorldPos = !find(Sentence, "world.");
44 int TooLong = !find(Sentence, "world.country");
48 // CHECK-NEXT: string Name = "Pat Snork"
49 // CHECK-NEXT: bit IsJr = 0
50 // CHECK-NEXT: bit JrOrSnork = 1
52 def Rec05 : C1<"Pat Snork"> {
53 bit JrOrSnork = !or(IsJr, !ne(!find(Name, "Snork"), -1));
58 // ERROR1: !find start position is out of range 0...29: 100
61 int Test1 = !find(Sentence, "the", 100);