Commit Graph

167 Commits

Author SHA1 Message Date
Alastair Robertson
a509354624 DrgnParser: Options should default to false
We only want to do the extra work if it's explicitly requested.

chaseRawPointers is already explicitly requested whenever it's needed
and readEnumValues currently isn't needed at all.
2023-09-19 18:32:37 +01:00
Jake Hillion
a6d74a20a6 Update to clang/llvm 15 (#342)
Summary:

Update to clang-15 compiler and libraries as clang-12 is ancient.

The changes to oilgen are necessary because the new internal toolchain is being more picky about linking PIC to PIC. In certain modes we build with PIC, but try to link a non-PIC oilgen artifact. Add the ability to build the oilgen artifacts with PIC which sorts this.

Reviewed By: ttreyer

Differential Revision: D46220858
2023-09-14 06:02:32 -07:00
Thierry Treyer
331c47705c Implement Container V2 for folly::small_vector 2023-09-08 16:34:34 +02:00
Thierry Treyer
465303cb99 Implement new container for F14ValueMap 2023-09-08 16:31:36 +02:00
Thierry Treyer
5d3aeec86d Implement new container for F14ValueSet 2023-09-08 16:31:36 +02:00
Thierry Treyer
0df6879f66 Implement Container V2 for F14FastSet 2023-09-08 16:31:36 +02:00
Thierry Treyer
a3d14d227f Implement Container V2 for F14NodeSet 2023-09-08 16:31:36 +02:00
Thierry Treyer
65fecf314a Implement Container V2 for F14VectorSet 2023-09-08 16:31:36 +02:00
Thierry Treyer
b327cf956b Implement Container V2 for F14FastMap 2023-09-07 18:47:09 +02:00
Thierry Treyer
b8e2770e2c Implement Container V2 for F14NodeMap 2023-09-07 18:47:09 +02:00
Thierry Treyer
d2a40b4f45 Implement Container V2 for F14VectorMap 2023-09-07 18:47:09 +02:00
Thierry Treyer
a5284549da Implement Container V2 for std::shared_ptr 2023-08-31 20:07:32 +02:00
Thierry Treyer
344023239b Add OILv2 tests for std::optional 2023-08-31 20:07:32 +02:00
Jake Hillion
a95d6f2187 add support for std::optional in treebuilder v2 2023-08-31 20:07:32 +02:00
Thierry Treyer
2699b4a665 Implement Container V2 for std::unique_ptr 2023-08-31 20:07:32 +02:00
Thierry Treyer
deb7dcdf1c Implement Container V2 for std::unordered_multiset 2023-08-30 18:45:00 +02:00
Thierry Treyer
54e01cfe27 Implement Container V2 for std::unordered_multimap 2023-08-30 18:45:00 +02:00
Thierry Treyer
7bdf72ec58 Implement Container V2 for std::unordered_map 2023-08-30 18:45:00 +02:00
Thierry Treyer
c1f322dc42 Implement Container V2 for std::unordered_set 2023-08-30 18:45:00 +02:00
Jake Hillion
d009f02ecb name contained types properly in treebuilder v2
Types within containers were previously named TODO. This sorts it out so
they're named as their most resolved type. The current implementation
skips Typedef names.
2023-08-25 16:25:14 +01:00
Thierry Treyer
1459433a50 Implement Container V2 for std::multiset 2023-08-25 16:07:10 +02:00
Thierry Treyer
f9b4d65cd8 Implement Container V2 for std::multimap 2023-08-25 16:07:10 +02:00
Thierry Treyer
19222a4fe2 Implement Container V2 for std::map 2023-08-25 15:13:55 +02:00
Alastair Robertson
03429f3da9 TypeGraph: Remove NodeTracker from the TypeGraph class
The TypeGraph class should only be responsible for storing Type nodes.
Traversing the graph and tracking which nodes have been visited should
not be included there.

Passes now take a NodeTrackerHolder as an input parameter, which
provides access to a zeroed-out NodeTracker.
2023-08-24 15:01:45 +01:00
Thierry Treyer
b8cb81e366 std::set implementation for Container V2 2023-08-24 13:57:27 +02:00
Jake Hillion
5071519e45 oil v2 2023-08-23 15:59:53 +01:00
Jake Hillion
c62fbe371d type_graph: provide inputName for all types
Type Graph deduplicates and modifies names to better fit the generated
code, for example `int32_t[4]` becomes `OIArray<int32_t, 4>` and `struct
MyStruct` might become `struct MyStruct_0`.

Add an `inputName` which better represents the original input code which
can be used when building the tree.
2023-08-18 16:58:21 +01:00
Alastair Robertson
373dbe8f6c TypeGraph: Add option to record enumerator names 2023-08-17 15:47:23 +01:00
Jake Hillion
a2f7462a5d DrgnParser: store type of template param value 2023-08-17 15:40:34 +01:00
Alastair Robertson
ff31971bd3 Printer: Use NodeIds for stable IDs when printing graphs
This removes Printer's legacy behaviour of generating an ID for each
node as it gets printed. This old method meant that if new nodes were
added to or removed from a graph, every ID after the new/removed node
would change.

Now IDs are stable so it is easier to follow specific nodes through
multiple transformation passes in CodeGen.
2023-08-16 12:19:14 +01:00
Alastair Robertson
97ba03620a TypeGraph: Convert unit tests relying on Printer to use TypeGraphParser 2023-08-14 15:01:09 +01:00
Alastair Robertson
e5a83a3a37 TopoSorterTest: Add test for value template params 2023-08-11 10:50:33 +01:00
Alastair Robertson
d45c7f4931 Flattener: Handle incomplete parent types 2023-08-02 14:29:19 +01:00
Alastair Robertson
0612159121 AlignmentCalc: Mark as packed if members are not aligned
We previously only marked as packed if there was no tail padding, which
was not a sufficient condition.

The new AlignmentCalcTest.PackedMembers test case is an example which
would previously not have been marked as packed.
2023-08-02 12:07:52 +01:00
Alastair Robertson
e9975286b2 NameGen: Fix naming of const pointers 2023-08-01 17:53:39 +01:00
Alastair Robertson
6fbb60826f
EnforceCompatibility: Stub out void pointers
CodeGen v1 does not record anything for pointers to incomplete types.
Not even the address, as is done for other pointers.

Introduce a new Primitive type "Incomplete". This behaves identically to
"Void", but allows us to tell whether a type was defined as void or if
it ended up like that because of incomplete DWARF information.
2023-07-31 14:28:05 +01:00
Alastair Robertson
7bb6791af9 AddPadding: Insert padding at the beginning of structs if necessary
This is sometimes needed now that we're removing members before adding
padding.
2023-07-27 16:01:35 +01:00
Jake Hillion
d7cfcca30d move all internal logic to oi::detail namespace 2023-07-26 18:01:38 +01:00
Alastair Robertson
e19641efad EnforceCompatibility: Follow OICodeGen's typesToStub list 2023-07-26 17:31:35 +01:00
Alastair Robertson
8b7bfbe4c0 TypeGraph: Add EnforceCompatibility pass
This extracts the compatibility logic from AddPadding, which allows for it to be
simplified and will make it easier to extend and eventually remove in the
future. No functional changes.
2023-07-26 17:12:36 +01:00
Alastair Robertson
45c3697f6b TypeGraph: Add Prune pass
This lets us remove fields from types when they are no longer needed,
speeding up later passes.

A secondary benefit of pruning unused types means that we sometimes
remove types for which we can't generate correct C++ code. This can
allow us to CodeGen for complex types which reference these broken types
without actually requiring them (e.g. as template parameters).

Add a new feature flag "prune-type-graph" to control this pass. It makes
sense to prune most of the time, but for testing CodeGen functionality
on a wider range of types, it will be useful to have the option to not
prune.
2023-07-26 16:56:34 +01:00
Alastair Robertson
bc895dc9cc DrgnParser: Always stub function pointers
This makes CodeGen v2 behave the same as CodeGen v1, and there doesn't
seem much point in following function pointers either.
2023-07-26 11:30:01 +01:00
Alastair Robertson
884b9a6e95 CodeGen: Don't measure the sizes of union members
In general, we can't tell which member is active in a union so it is not
safe to try and measure any of them.

Explicitly set the alignment of unions (and structs/classes) in CodeGen
if it is available, as the C++ compiler can no longer infer it from the
members.
2023-07-26 11:16:30 +01:00
Alastair Robertson
2d1cc92bb4 Rename RemoveIgnored -> RemoveMembers
Also reshuffle CodeGen's passes to fix an alignment bug with removed
members.

Change RemoveMembers to actually remove members instead of replacing
them with padding. AddPadding must be run afterwards to fill in the
gaps.
2023-07-26 10:53:04 +01:00
Alastair Robertson
99462b2132 Types: Fix folly::small_vector and folly::sorted_vector_map
folly::sorted_vector_map's results are not completely accurate, but at
least CodeGen v2 matches CodeGen v1 for it now.
2023-07-26 10:07:30 +01:00
Alastair Robertson
e1496354de TopoSorter: Sort Typedefs before pointers
Also rename visitAfter() to acceptAfter() to match the previous renaming
of visit() to accept().
2023-07-25 15:31:35 +01:00
Alastair Robertson
df5ae4e34c AlignmentCalc: Array alignment should be based on elementType's alignment 2023-07-25 14:23:01 +01:00
Alastair Robertson
dfc0c62749 AlignmentCalc: Tests for bitfields
Extend TypeGraphParser to understand bitfields
2023-07-25 14:23:01 +01:00
Alastair Robertson
14d193df64 AlignmentCalc: Recurse into params,parents,members,children of Classes 2023-07-25 14:23:01 +01:00
Alastair Robertson
04ce7446b2 AddPadding: Always pad bitfields with "int8_t"s
The underlying type of bitfield is important to the size of a struct:

  struct Foo { int64_t bitfield : 1; };
  struct Bar { int8_t bitfield : 1; };

  sizeof(Foo) = 8;
  sizeof(Bar) = 1;
2023-07-24 16:55:26 +01:00