2 GCC Assembly Templates
Krystian Bacławski edited this page 2013-10-05 12:52:37 +02:00

GCC Assembly Templates

Taken from GCC documentation under: Operand Constraints.

Simple constraints

m A memory operand is allowed, with any kind of address that the machine supports in general.

o A memory operand is allowed, but only if the address is offsettable. This means that adding a small integer (actually, the width in bytes of the operand, as determined by its machine mode) may be added to the address and the result is also a valid memory address.

V A memory operand that is not offsettable. In other words, anything that would fit the m constraint but not the o constraint.

< A memory operand with autodecrement addressing (either predecrement or postdecrement) is allowed.

> A memory operand with autoincrement addressing (either preincrement or postincrement) is allowed.

r A register operand is allowed provided that it is in a general register.

d, a, f Other letters can be defined in machine-dependent fashion to stand for particular classes of registers. d, a and f are defined on the m68k to stand for data, address and floating point registers.

i An immediate integer operand (one with constant value) is allowed. This includes symbolic constants whose values will be known only at assembly time.

F An immediate floating operand (expression code const_double) is allowed.

g Any register, memory or immediate integer operand is allowed, except for registers that are not general registers.

0, 1, 2, ... 9 An operand that matches the specified operand number is allowed. If a digit is used together with letters within the same alternative, the digit should come last.

Constraint modifier characters

= Means that this operand is write-only for this instruction: the previous value is discarded and replaced by output data.

+ Means that this operand is both read and written by the instruction. When the compiler fixes up the operands to satisfy the constraints, it needs to know which operands are inputs to the instruction and which are outputs from it.

& Means (in a particular alternative) that this operand is an earlyclobber operand, which is modified before the instruction is finished using the input operands. Therefore, this operand may not lie in a register that is used as an input operand or as part of any memory address. & does not obviate the need to write =.

% Declares the instruction to be commutative for this operand and the following operand. This means that the compiler may interchange the two operands if that is the cheapest way to make all operands fit the constraints. This is often used in patterns for addition instructions that really have only two operands: the result must go in one of the arguments.