Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Write and parse ABI annotations on function signatures #49

Closed
stoklund opened this issue Feb 24, 2017 · 3 comments
Closed

Write and parse ABI annotations on function signatures #49

stoklund opened this issue Feb 24, 2017 · 3 comments
Labels
E-easy Issues suitable for newcomers to investigate, including Rust newcomers!

Comments

@stoklund
Copy link
Contributor

In c8be39f I added support for ABI annotations on function signatures. These annotations indicate the location (stack or register) of individual function arguments and return values. We need:

  • Support for writing the ABI annotations using the correct ISA names for registers.
  • Support for parsing the ABI annotations in test files with a single unique ISA. Related to Parse encodings #24.

Writing ABI annotations

The new syntax for function signatures is partially implemented:

function average(i32 [%x10], i32 inreg [%x11]) -> f32 [%f10] {

If a signature has ABI annotations, they appear in brackets after each argument or return value. This is used everywhere function signatures appear:

  • In the function definition.
  • In a signature declaration in the preamble.
  • In a function declaration in the preamble.

Each argument is annotated as follows:

  • Registers: [%x10] using the display_regunit() function provided by the TargetIsa. Note that the currently committed implementation is incorrect, it just prints the register unit number [%10]. This is a stopgap until we can provide a &TargetIsa reference. It is not a syntax we want to support going forward.
  • Stack arguments: [24], where the number in brackets is the argument's byte offset in the argument array.
  • Unassigned arguments don't get an annotation in the text format.

The Signature struct also has an argument_bytes field now which indicates the needed size of the argument array. This field does not need to appear in the text format since it can be computed from the arguments.

Parsing ABI annotations

The parser should accept the annotations above and fill in the location field of the ArgumentType structs when present.

When parsing a file that doesn't specify exactly one ISA, the ABI annotations should be ignored.

After parsing a signature containing with ABI annotations, call the Signature::compute_argument_bytes() method.

@stoklund stoklund added the E-easy Issues suitable for newcomers to investigate, including Rust newcomers! label Feb 24, 2017
@stoklund
Copy link
Contributor Author

stoklund commented Mar 3, 2017

I've implemented the display part of this one, with a test case in filetests/isa/riscv/abi.cton. Maybe the remaining parser work is for @angusholder ?

@angusholder
Copy link
Contributor

I'll get onto this now

@stoklund
Copy link
Contributor Author

stoklund commented Mar 9, 2017

Fixed by @angusholder !

@stoklund stoklund closed this as completed Mar 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
E-easy Issues suitable for newcomers to investigate, including Rust newcomers!
Projects
None yet
Development

No branches or pull requests

2 participants