mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-01 16:33:37 +01:00
26054a566e
def/var/string substitution on generic pattern templates. For example: def Type; def v4f32 : Type; def TYPE : Type; class GenType<Type t> { let type = !(subst TYPE, v4f32, t); } def TheType : GenType<TYPE>; llvm-svn: 71801
30 lines
846 B
TableGen
30 lines
846 B
TableGen
// RUN: tblgen %s | grep {Smith} | count 7
|
|
// RUN: tblgen %s | grep {Johnson} | count 2
|
|
// RUN: tblgen %s | grep {FIRST} | count 1
|
|
// RUN: tblgen %s | grep {LAST} | count 1
|
|
// RUN: tblgen %s | grep {TVAR} | count 2
|
|
// RUN: tblgen %s | grep {Bogus} | count 1
|
|
|
|
class Honorific<string t> {
|
|
string honorific = t;
|
|
}
|
|
|
|
def Mr : Honorific<"Mr.">;
|
|
def Ms : Honorific<"Ms.">;
|
|
def Mrs : Honorific<"Mrs.">;
|
|
def TVAR : Honorific<"Bogus">;
|
|
|
|
class Name<string n, Honorific t> {
|
|
string name = n;
|
|
Honorific honorific = t;
|
|
}
|
|
|
|
class AName<string name, Honorific honorific> :
|
|
Name<!subst("FIRST", "John", !subst("LAST", "Smith", name)),
|
|
!subst(TVAR, Mr, honorific)>;
|
|
|
|
def JohnSmith : AName<"FIRST LAST", TVAR>;
|
|
def JaneSmith : AName<"Jane LAST", Ms>;
|
|
def JohnSmithJones : AName<"FIRST LAST-Jones", Mr>;
|
|
def JimmyJohnson : AName<"Jimmy Johnson", Mr>;
|