Class Voodoo::ARMGasGenerator
In: voodoo/generators/arm_gas_generator.rb
Parent: CommonCodeGenerator

ARM GNU Assembler Code Generator

The ARM code generator generates assembly code for use with the GNU assembler.

Calling Convention

The first four arguments are passed in the registers r0 through r3. Any additional arguments are passed on the stack, starting at r13. r13 will always be a multiple of 8.

The return address for the called function is passed in r14.

The called function will store its return value in r0.

The called function is required to preserve the values of registers r4 through r11 and register r13.

This calling convention is compatible with the Procedure Call Standard for the ARM Architecture (AAPCS).

Call Frames

Call frames have the following layout:

When a function is called, it receives a stack frame that looks like the following:

  :
  old frame
  padding
  argn
  :
  arg4        <-- r13 points here

The function prologue of functions generated by this code generator creates activation frames that look as follows:

  :
  old frame
  padding
  argn
  :
  arg4
  saved r14
  saved r11
  :
  saved r4   <-- r13 points here

Register Usage

Inside a function, registers r4..r8, r10, and r11 are used for local variables and function arguments.

r12 is used as a temporary, and r3 is used when another temporary is needed.

Methods

Public Class methods

Public Instance methods

Create an entry in the constants table, returning the label that will refer to the constant. The value may be an integer or a label.

Returns an sp-relative reference for the nth (0-based) argument.

Return the register in which the nth (0-based) argument is stored, or nil if not stored in a register

Test if op is a binary operation

Test if a value is an at-expression

Begins a new block.

Emit function prologue and declare formals as function arguments

Test if op is a binary operation

Define a byte with the given value

Start a conditional using the specified branch instruction after the comparison.

Counts the number of local variables created in a sequence of statements.

Creates a stack frame for the given number of arguments and local variables.

Destroys the current stack frame. If ret is true, loads the saved value of lr into pc.

Writes any constants that need to be written to the instruction stream, and clears the list of constants that need to be written.

Ends the current block.

Ends a conditional.

Evaluate the binary operation expr and store the result in register

Evaluates the expression expr and stores the result in register.

Export symbols from the current section

Add a function to the current section

Load byte from base + offset into register

Load word from base + offset * _@WORDSIZE_ into register

Test if a symbol refers to a global

Jump to a label.

Grows the current frame by n words, plus padding to respect alignment rules.

Start the false path of a conditional.

Test if x is equal to y

Test if x is greater than or equal to y

Test if x is strictly greater than y

Test if x is less than or equal to y

Test if x is strictly less than y

Test if x different from y

Import labels into the current section

Test if a value is an integer

Introduce a new local variable

Load the value at the given address.

Load a value into a register. Returns the name of the register. If the value was already in a register, the name of that register is returned. Else, the value is loaded into a register and the name of that register is returned. The register to use in that case may be specified using the optional second argument.

Load a value into a specific register

Returns an sp-relative reference for the nth (0-based) local.

Return the register in which the nth local (0-based) is stored, or nil if not stored in a register

Calculate the number of register arguments, given the total number of arguments.

Calculate the number of stack arguments, given the total number of arguments.

Returns true if the nth (0-based) argument is stored in a register

Returns true if the nth (0-based) local is stored in a register

Returns from a function.

words may contain an expression to be evaluated. The result of the evaluation is returned from the function.

Set a variable to the result of evaluating an expression

Set the byte at base + offset to value

Set the word at base + offset * +@WORDSIZE+ to value

Define a string with the given value

Test if a value is a symbol

Test if op is a symmetric binary operation (i.e. it will yield the same result if the order of its source operands is changed).

Call a function, re-using the current call frame if possible.

Define a word with the given value

Write generated code to the given IO object.

[Validate]