Commit Graph

23 Commits

Author SHA1 Message Date
Pietro Fezzardi 2ab5b5d9bf Fix handling of UndefValue and PoisonValue 2022-11-30 18:16:13 +01:00
Ivan Krysak 654afbef0c Move pointer creation away from model::Binary 2022-11-30 18:16:13 +01:00
Massimo Fioravanti 335d402245 Change signatures to forward metadata cache. 2022-11-22 12:27:02 +01:00
Pietro Fezzardi eef93f2a85 InitModelTypes: handle CABIFunctionType
Before this commit, the code assumed that whenever we had multiple
return types on the model we had an aggregate return type also in LLVM
IR. This is not true anymore with CABIFunctionType, where many model
types can be stuffed into a single wide integer in LLVM IR.

This commit fixes the code to be able to handle that situation.
2022-11-09 11:59:51 +01:00
Pietro Fezzardi 25119c4377 Drop bugged addPointerQualifier for getPointerTo
This commit removes the bugged addPointerQualifier helper function,
that was wrongly pushing the pointer qualifier at the end.

Instead, we now use the correct model::Binary::getPointerTo method.
2022-10-21 09:45:28 +02:00
Pietro Fezzardi 887701e6f0 InitModelTypes: better support CABIFunctionType 2022-10-20 10:22:20 +02:00
Alvise de Faveri c5e24053a7 Run VMA during InitModelTypes 2022-07-18 15:37:31 +02:00
Alvise de Faveri a788a5ba62 Add helpers for inferring model types from the IR
1. Add a common helper to traverse ModelGEPs (`traverseModelGEP`)
2. Add a centralized way to deduce the model type of values that
   have strong model information attached to them (e.g. isolated
   functions and ModelGEPs)
3. Add a similar helper for deducing formal types of operands in known
   cases
2022-07-18 15:37:31 +02:00
Alvise de Faveri c2481aeb7b Support: Add deserializeFromLLVMString
Instead of having `paseQualifiedType` and `parseAndDeserialize`,
we now have a single function that is symmetric to
`serializeToLLVMString`.
2022-07-15 17:17:04 +02:00
Alvise de Faveri 2ffa537605 IRCanonicalization: Add Copy()
Use the `Copy` opcode to substitute load instructiobs.
2022-06-28 10:28:38 +02:00
Alvise de Faveri 6b258c83a1 IRCanonicalization: Fold ModelGEP(AddressOf())
- `FoldModelGEP` folds `ModelGEP(AddressOf())` into `ModelGEPRef`
- `RemoveRefDeref` remove `ModelGEPRef`s with no arguments
2022-06-28 10:26:50 +02:00
Alvise de Faveri 123a1777cd IRCanonicalization: Add RemoveLoadStore pass 2022-06-28 10:25:49 +02:00
Alvise de Faveri f7866ddd85 IRCanonicalization: Add MakeLocalVariables pass 2022-06-28 10:24:48 +02:00
Alvise de Faveri da46b38644 Backend: Various improvements to variables declaration 2022-06-28 10:24:18 +02:00
Alvise de Faveri 221b8f74d9 Add reference semantics to stack opcodes
`revng_stack_frame` and `revng_stack_args` are treated as returning
a reference, and are always followed by an `AddressOf` call.
2022-06-28 10:23:45 +02:00
Alvise de Faveri de334a92e9 Backend: Make IntToPtr and PtrToInt transparent 2022-06-28 10:12:22 +02:00
Antonio Frighetto cd65fd1554 Introduce OperatorPrecedenceResolutionPass
A simple pass that maps LLVM IR instructions to C operators,
taking into account their precedence and associativity to
emit nice-looking parenthesized expressions.
2022-06-15 10:28:50 +02:00
Antonio Frighetto 4a045cce53 Introduce MakeModelCastPass
A pass that strips the casts off from some instructions, including
`ModelGEP`s, general function calls, return and store ones, and
embeds the cast into new dedicated `ModelCast` function calls.
2022-06-15 10:28:50 +02:00
Alvise de Faveri 5a41669d2e ModelGEP: Never initialize types from LLVM IR 2022-06-13 15:19:15 +02:00
Pietro Fezzardi 4ed636cbba Support emission in C of null pointers 2022-05-31 12:40:52 +02:00
Pietro Fezzardi 35e0e688d2 Support emission in C of integer or pointers undef 2022-05-31 12:40:52 +02:00
Pietro Fezzardi b909bb6629 New MarkAssignments library in IRCanonicalization
This library replaces the old AddIRSerializationMarkers, cleaning up a
lot of historcal baggage, merging Liveness and MarkAnalysis, and
adopting a more accurate naming across all the codebase.
2022-04-21 18:13:51 +02:00
Alvise de Faveri 3fe9f687cc Move TypeMap initialization to InitModelTypes
Move the code that initializes the TypeMap in a separate library,
that will be shared between ModelGEP and the backend.
2022-04-20 17:35:05 +02:00