Commit Graph

63 Commits

Author SHA1 Message Date
Alessandro Di Federico 52521f8cac Adopt more standard library's features 2023-04-08 08:42:23 +02:00
Ivan Krysak 19e292f097 abi::FunctionType: standardize std integer usage
This reevaluates the places where `std::size_t` should be replaced by
`std::uint64_t` in the conversions, it also appends `std::` prefixes to
them where it's possible in preparation to the eventual `import std`
transition.
2023-03-15 10:19:03 +01:00
Ivan Krysak 1f27e938bf ABI: rework non-position based distribution
The original non-position based distribution (`considerRegisters`)
algorithm had a whole lot of problems preventing effective padding
support because it was written with only registers in mind.

As such, it was easier to rewrite the whole logic from scratch over
trying to fix it incrementally.
2023-03-15 10:19:03 +01:00
Ivan Krysak b8b1a716ed ABI: let NoOrDead painlessly decay to No 2023-03-15 10:19:03 +01:00
Ivan Krysak 2dfe65f65c ABI: purge unnamed types when analyses are done 2023-03-15 10:19:03 +01:00
Ivan Krysak 17c128c59b Make ABI depend on ModelPasses
Before now the dependency was the other way around
2023-03-15 10:19:03 +01:00
Ivan Krysak 158272dee5 ABI: add an analysis for ToCABI conversion 2023-03-15 10:19:03 +01:00
Ivan Krysak 952b938598 ABI: add an analysis for ToRaw conversion 2023-03-15 10:19:03 +01:00
Ivan Krysak 3d05439001 ABI: improve multi-aligned stack argument support 2023-03-15 10:19:03 +01:00
Ivan Krysak 3edfaa827f ABI: preserve big scalar return values if possible 2023-03-15 10:19:03 +01:00
Ivan Krysak a936990c77 ABI: abstract stack alignment verification away 2023-03-15 10:19:03 +01:00
Ivan Krysak 806d4053a0 ABI: reintroduce conversion logs 2023-03-15 10:19:03 +01:00
Ivan Krysak 09f1d5b5e7 ABI: rework stack argument conversion 2023-03-15 10:19:03 +01:00
Ivan Krysak a0adafeab0 ABI: take advantage of register state deductions
This makes the conversions more robust, since everything can rely on
the same tools for filling in missing registers and ordering them based
on the ABI requirements.
2023-03-15 10:19:03 +01:00
Ivan Krysak 0c82ff91b1 ABI: move the conversion ouside the helper class
This will allow reusing the helper class as the type manager.
2023-03-15 10:19:03 +01:00
Ivan Krysak 3422a9bf0f ABI: reintoduce conversion logs 2023-03-15 10:19:03 +01:00
Ivan Krysak b966637373 Layout: improve shadow return value handling
This brings the layout-side handling of these closer to the way they are
handled when converting the function.

The biggest change is the fact that now the return value location can
also be passed as the first stack argument.
2023-03-15 10:19:03 +01:00
Ivan Krysak a093d166b1 ABI: revamp basic floating point argument handling
This was a necessary change because without at least basic shortcuts
introduced here, we get a whole lot of failures downstream due to
layouts of such functions and the layout production is by design not
allowed to fail.
2023-03-15 10:19:03 +01:00
Ivan Krysak 9f7427c776 ABI: fix desynchronization of argument indices
When a shadow return value location argument is distributed, it is
shifting all the other argument indices by one. This was not taken into
the account previously. This commit fixes the indices.

It also makes it so the arguments `SizeOnStack` does not account for
padding. This is useful for some layout users.
2023-03-15 10:19:03 +01:00
Ivan Krysak f7be81737b ToRawConverter: don't attempt to recover types 2023-03-15 10:19:03 +01:00
Ivan Krysak 5bf13ac420 ABI: restructure ToRaw conversion root
This reorders the algorithms, so that the return values are handled
before the arguments. It also improves the wordind and extends
the comments annotating the function.

Moreover, it takes advantage of the `TypeBucket` to decouple type
management from the "raw" binary.
2023-03-15 10:19:02 +01:00
Ivan Krysak 4ecb88ab9d ABI: move ToCABIConverter onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 51beb8fc1b ABI: move ToRawConverter onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 59d3b627a1 ABI: simplify default prototype stack traces 2023-03-15 10:19:02 +01:00
Ivan Krysak 039de1fe6d ABI: move function prototype onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 9e393578c9 ABI: move state deduction onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 84229d92b1 Model & ABI: make size and alignment stricter 2023-03-15 10:19:02 +01:00
Ivan Krysak 769e5c1cbe ABI: add a natural alignment calculation helper 2023-03-15 10:19:02 +01:00
Ivan Krysak 8b675e131e ABI: introduce runtime abi definition 2023-03-15 10:19:02 +01:00
Ivan Krysak 87bded80d3 ABI: rename RegisterList into RegisterVector 2023-03-15 10:19:02 +01:00
Ivan Krysak 3d3348b84a ABI: rename Converter into ToCABIConverter
This also moves members definitions outside the class boundaries
2023-03-15 10:19:02 +01:00
Ivan Krysak b1b9453585 ABI: rename Converter into ToRawConverter
This also moves members definitions outside the class boundaries
2023-03-15 10:19:02 +01:00
Ivan Krysak 0e8aee95e9 ABI: rename ArgumentContainer into ArgumentSet 2023-03-15 10:19:02 +01:00
Ivan Krysak 395191cdf1 ABI: use replaceReferencesIf when updating types 2023-03-15 10:19:02 +01:00
Ivan Krysak 01a05e2037 ABI: separate convertions based on the direction 2023-03-15 10:19:02 +01:00
Ivan Krysak 2f3128cb43 ABI: separate reused helpers into Support.h 2023-03-15 10:19:02 +01:00
Ivan Krysak 67bc7f8331 ABI: rename TheBinary into Binary 2023-03-15 10:19:02 +01:00
Ivan Krysak 058807ca00 model::Register: rename getArchitecture
The new name is `getReferenceArchitecture`
2023-03-15 10:19:02 +01:00
Ivan Krysak 0b1aaeaede Minor improvements 2023-03-15 10:19:01 +01:00
Massimo Fioravanti 742e1a0c56 TupleTree: switch from public fields to accessors 2022-12-12 18:36:57 +01:00
Pietro Fezzardi e62aa0166e FunctionType::Layout: introduce argument kind
This commit introduces a `Kind` for arguments described in
`FunctionType::Layout`. We nowe basically have three types of arguments:

* Scalar: a regular scarlar argument;
* ReferenceToAggregate: a reference to an aggregete argument on the
  stack;
* ShadowPointerToAggregateReturnValue: a pointer to the storage for the
  (aggregate) return value allocated by the caller;
2022-11-30 15:06:54 +01:00
Ivan Krysak e49f397d13 Layout: work around vector return value problems 2022-11-30 15:06:54 +01:00
Ivan Krysak 855999f5f0 Layout: add support for multiple return values 2022-11-30 15:06:54 +01:00
Ivan Krysak 535c9dd346 ABI: remove MinimumStackArgumentSize value
The architecture-specific pointer (generic register) size is used
instead.

For all the ABIs we support the value of this parameter was already
set to its pointer size. We might need to reintroduce the parameter
in the future if we want to support a super-exotic ABI with different
stack alignment requirements, but that seems highly unlikely.

This also introduces the argument extension helper for one stop all
treating small arguments when they are put into a register or pushed
into the stack.
2022-11-30 15:06:54 +01:00
Alessandro Di Federico f2bd49d562 defaultPrototype: set FinalStackOffset 2022-08-08 13:55:26 +02:00
Ivan Krysak 66c96fb128 ABI: improve RegisterStateDeductions
Split the interface into two functions: `enforce.*` returning the map by
value and `tryApply.*` returning an `std::optional`.

Improve non-positional single deduction function to better reflect
some corner cases (for example how a required `NoOrDead` register
argument is handled).

Enforce a position-based deduction corner case where it's impossible to
deduce whether the argument is passed in the GPR or the vector one -
now GPR takes precedence in those cases.
2022-04-15 18:25:11 +02:00
Pietro Fezzardi e40ded965f QualifiedType RawFunctionType.StackArgumentsType
The `StackArgumentsType` field of `RawFunctionType` was the only
cross-reference between `model::Type`s that did not use
`model::QualifiedType` but a naked `TupleTreeReference`.

Switching it to `QualifiedType` make all cross-references across
`model::Type`s homogeneous.
2022-04-08 18:58:58 +02:00
Ivan Krysak a10415fd0b Make the function layout argument type aware 2022-03-28 15:43:34 +02:00
Ivan Krysak 1b03adca5e Make function type convertions self-sufficient 2022-03-28 15:38:04 +02:00
Ivan Krysak f614a8cf7f Implement ABI SystemV_x86_64 stack support 2022-03-28 15:38:04 +02:00