[llvm-dev] Another possible tracing feature for TableGen
Paul C. Anagnostopoulos via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 14 10:56:43 PDT 2020
I hacked around a bit with the simple case of tracing just classes and defs (no multiclasses or defms). Below you will see my test file and then the output produced. Note that the regular output from the PrintRecords backend follows the trace, so you can see the final classes and records there. Once the trace can be selective, it makes sense to add another option for PrintRecords that restricts its printing to only the traced records.
Now it gets a bit more difficult.
===============================================
class P <int ID> {
int P_ID = ID;
string P_field = "P string here";
}
class C <string arg1> : P<-1970> {
int C_field1 = 1042;
string C_field2 = "C string";
int C_field3;
let C_field3 = !add(C_field1, 3);
string C_arg1 = arg1;
string C_to_let;
}
class D <list<int> list1, int rare = 0> {
list<int> D_list = list1;
int D_rare = rare;
int D_field1 = 10101;
int D_field2 = 10102;
bits<4> D_bits = {1, 0, 1, 0};
}
let C_to_let = "C to let" in
let D_field2 = -10102 in {
def rec1 : C<"arg1_val">, D<[13, 14, 15]> {
defvar var1 = -1;
defvar var2 = "base string";
int num = 42;
list<string> list_a;
string str = "Hello world!";
string from_var2 = var2 # " from var2";
int num2 = !mul(3, num);
let num = 43;
let str = from_var2 # " with let";
}
} // let
====================================================
~~~~~~~~~~~~~ Trace class P ~~~~~~~~~~~~~
<class's template args should be listed here>
~~~ No inherited classes
~~~ No pending lets
~~~ Local items (possibly unresolved):
field P_ID = P:ID
field P_field = "P string here"
~~~~~~~~~~~~~ Trace class C ~~~~~~~~~~~~~
~~~ Inherited classes:
P
template arg. default P:ID = ?
template arg. passed P:ID = -1970
field P_ID = P:ID
field P_field = "P string here"
~~~ No pending lets
~~~ Local items (possibly unresolved):
field C_field1 = 1042
field C_field2 = "C string"
field C_field3 = ?
let C_field3 = !add(C_field1, 3)
field C_arg1 = C:arg1
field C_to_let = ?
~~~~~~~~~~~~~ Trace class D ~~~~~~~~~~~~~
~~~ No inherited classes
~~~ No pending lets
~~~ Local items (possibly unresolved):
field D_list = D:list1
field D_rare = D:rare
field D_field1 = 10101
field D_field2 = 10102
field D_bits = { 1, 0, 1, 0 }
~~~~~~~~~~~~~ Trace record rec1 ~~~~~~~~~~~~~
~~~ Inherited classes:
C
template arg. default C:arg1 = ?
template arg. passed C:arg1 = "arg1_val"
field P_ID = -1970
field P_field = "P string here"
field C_field1 = 1042
field C_field2 = "C string"
field C_field3 = !add(C_field1, 3)
field C_arg1 = C:arg1
field C_to_let = ?
D
template arg. default D:list1 = ?
template arg. default D:rare = 0
template arg. passed D:list1 = [13, 14, 15]
field D_list = D:list1
field D_rare = D:rare
field D_field1 = 10101
field D_field2 = 10102
field D_bits = { 1, 0, 1, 0 }
~~~ Pending lets:
let C_to_let = "C to let"
let D_field2 = -10102
~~~ Local items (possibly unresolved):
defvar var1 = -1
defvar var2 = "base string"
field num = 42
field list_a = ?
field str = "Hello world!"
field from_var2 = "base string from var2"
field num2 = !mul(3, num)
let num = 43
let str = !strconcat(from_var2, " with let")
------------- Classes -----------------
class C<string C:arg1 = ?> { // P
int P_ID = -1970;
string P_field = "P string here";
int C_field1 = 1042;
string C_field2 = "C string";
int C_field3 = !add(C_field1, 3);
string C_arg1 = C:arg1;
string C_to_let = ?;
}
class D<list<int> D:list1 = ?, int D:rare = 0> {
list<int> D_list = D:list1;
int D_rare = D:rare;
int D_field1 = 10101;
int D_field2 = 10102;
bits<4> D_bits = { 1, 0, 1, 0 };
}
class P<int P:ID = ?> {
int P_ID = P:ID;
string P_field = "P string here";
}
------------- Defs -----------------
def rec1 { // P C D
int P_ID = -1970;
string P_field = "P string here";
int C_field1 = 1042;
string C_field2 = "C string";
int C_field3 = 1045;
string C_arg1 = "arg1_val";
string C_to_let = "C to let";
list<int> D_list = [13, 14, 15];
int D_rare = 0;
int D_field1 = 10101;
int D_field2 = -10102;
bits<4> D_bits = { 1, 0, 1, 0 };
int num = 43;
list<string> list_a = ?;
string str = "base string from var2 with let";
string from_var2 = "base string from var2";
int num2 = 129;
}
===================================================
----------------------------------------------------------------
Windfall Paul C. Anagnostopoulos
----------------------------------------------------------
Software 978 369-0839
www.windfall.com
----------------------------------------------------------------
My life has been filled with calamities,
some of which actually happened.
---Mark Twain
Guga 'mzimba, sala 'nhliziyo
More information about the llvm-dev
mailing list