libFirm

A method type represents a method, function or procedure type. More...

Macros

#define cc_bits   (0xFF000000)
 
#define cc_cdecl_set   (0)
 cdecl calling convention More...
 
#define cc_stdcall_set   cc_callee_clear_stk
 stdcall calling convention More...
 
#define cc_fastcall_set   (cc_reg_param|cc_callee_clear_stk)
 fastcall calling convention More...
 
#define IS_CDECL(cc_mask)   (((cc_mask) & cc_bits) == cc_cdecl_set)
 check for the CDECL calling convention More...
 
#define IS_STDCALL(cc_mask)   (((cc_mask) & cc_bits) == cc_stdcall_set)
 check for the STDCALL calling convention More...
 
#define IS_FASTCALL(cc_mask)   (((cc_mask) & cc_bits) == cc_fastcall_set)
 check for the FASTCALL calling convention More...
 
#define SET_CDECL(cc_mask)   (((cc_mask) & ~cc_bits) | cc_cdecl_set)
 Sets the CDECL convention bits. More...
 
#define SET_STDCALL(cc_mask)   (((cc_mask) & ~cc_bits) | cc_stdcall_set)
 Sets the STDCALL convention bits. More...
 
#define SET_FASTCALL(cc_mask)   (((cc_mask) & ~cc_bits) | cc_fastcall_set)
 Sets the FASTCALL convention bits. More...
 

Enumerations

enum  mtp_additional_properties {
  mtp_no_property = 0, mtp_property_no_write = 1u << 0, mtp_property_pure = 1u << 1, mtp_property_noreturn = 1u << 2,
  mtp_property_terminates = 1u << 3, mtp_property_nothrow = 1u << 4, mtp_property_naked = 1u << 5, mtp_property_malloc = 1u << 6,
  mtp_property_returns_twice = 1u << 7, mtp_property_private = 1u << 8, mtp_property_always_inline = 1u << 9, mtp_property_noinline = 1u << 10,
  mtp_property_inline_recommended = 1u << 11, mtp_temporary = 1u << 12, mtp_property_is_constructor = 1u << 13
}
 Additional method type properties: Tell about special properties of a method type. More...
 
enum  calling_convention {
  cc_reg_param = 0x01000000, cc_last_on_top = 0x02000000, cc_callee_clear_stk = 0x04000000, cc_this_call = 0x08000000,
  cc_compound_ret = 0x10000000, cc_frame_on_caller_stk = 0x20000000, cc_fpreg_param = 0x40000000
}
 Calling conventions: lower 24 bits are the number of register parameters, upper 8 encode the calling conventions. More...
 

Functions

ir_typenew_type_method (size_t n_param, size_t n_res, int is_variadic, unsigned cc_mask, mtp_additional_properties property_mask)
 Create a new method type. More...
 
size_t get_method_n_params (const ir_type *method)
 Returns the number of parameters of this method. More...
 
ir_typeget_method_param_type (const ir_type *method, size_t pos)
 Returns the type of the parameter at position pos of a method. More...
 
void set_method_param_type (ir_type *method, size_t pos, ir_type *tp)
 Sets the type of the parameter at position pos of a method. More...
 
size_t get_method_n_ress (const ir_type *method)
 Returns the number of results of a method type. More...
 
ir_typeget_method_res_type (const ir_type *method, size_t pos)
 Returns the return type of a method type at position pos. More...
 
void set_method_res_type (ir_type *method, size_t pos, ir_type *tp)
 Sets the type of the result at position pos of a method. More...
 
int is_method_variadic (ir_type const *method)
 Returns the variadicity of a method. More...
 
mtp_additional_properties get_method_additional_properties (const ir_type *method)
 Returns the mask of the additional graph properties. More...
 
unsigned get_method_calling_convention (const ir_type *method)
 Returns the calling convention of an entities graph. More...
 
unsigned get_method_n_regparams (ir_type *method)
 Returns the number of registers parameters, 0 means default. More...
 
int is_Method_type (const ir_type *method)
 Returns true if a type is a method type. More...
 

Detailed Description

A method type represents a method, function or procedure type.

It contains a list of the parameter and result types, as these are part of the type description. These lists should not be changed by an optimization, as a change creates a new method type. Therefore optimizations should allocate new method types. set_method_param_type() and set_method_res_type() are only for construction by a frontend.

Macro Definition Documentation

◆ cc_bits

#define cc_bits   (0xFF000000)

Definition at line 1247 of file typerep.h.

◆ cc_cdecl_set

#define cc_cdecl_set   (0)

cdecl calling convention

Definition at line 1250 of file typerep.h.

◆ cc_fastcall_set

#define cc_fastcall_set   (cc_reg_param|cc_callee_clear_stk)

fastcall calling convention

Definition at line 1254 of file typerep.h.

◆ cc_stdcall_set

#define cc_stdcall_set   cc_callee_clear_stk

stdcall calling convention

Definition at line 1252 of file typerep.h.

◆ IS_CDECL

#define IS_CDECL (   cc_mask)    (((cc_mask) & cc_bits) == cc_cdecl_set)

check for the CDECL calling convention

Definition at line 1259 of file typerep.h.

◆ IS_FASTCALL

#define IS_FASTCALL (   cc_mask)    (((cc_mask) & cc_bits) == cc_fastcall_set)

check for the FASTCALL calling convention

Definition at line 1269 of file typerep.h.

◆ IS_STDCALL

#define IS_STDCALL (   cc_mask)    (((cc_mask) & cc_bits) == cc_stdcall_set)

check for the STDCALL calling convention

Definition at line 1264 of file typerep.h.

◆ SET_CDECL

#define SET_CDECL (   cc_mask)    (((cc_mask) & ~cc_bits) | cc_cdecl_set)

Sets the CDECL convention bits.

Definition at line 1274 of file typerep.h.

◆ SET_FASTCALL

#define SET_FASTCALL (   cc_mask)    (((cc_mask) & ~cc_bits) | cc_fastcall_set)

Sets the FASTCALL convention bits.

Definition at line 1284 of file typerep.h.

◆ SET_STDCALL

#define SET_STDCALL (   cc_mask)    (((cc_mask) & ~cc_bits) | cc_stdcall_set)

Sets the STDCALL convention bits.

Definition at line 1279 of file typerep.h.

Enumeration Type Documentation

◆ calling_convention

Calling conventions: lower 24 bits are the number of register parameters, upper 8 encode the calling conventions.

Enumerator
cc_reg_param 

Transmit parameters in registers, else the stack is used.

This flag may be set as default on some architectures.

cc_last_on_top 

The last non-register parameter is transmitted on top of the stack.

This is equivalent to the pascal calling convention. If this flag is not set, the first non-register parameter is used (stdcall or cdecl calling convention)

cc_callee_clear_stk 

The callee clears the stack.

This forbids variadic function calls (stdcall).

cc_this_call 

The first parameter is a this pointer and is transmitted in a special way.

cc_compound_ret 

The method returns a compound type.

cc_frame_on_caller_stk 

The method did not allocate an own stack frame, instead the caller must reserve size on its own stack.

cc_fpreg_param 

Transmit floating point parameters in registers, else the stack is used.

Definition at line 1228 of file typerep.h.

◆ mtp_additional_properties

Additional method type properties: Tell about special properties of a method type.

Some of these may be discovered by analyses.

Enumerator
mtp_no_property 

No additional properties.

mtp_property_no_write 

This method does not change any memory known to the rest of the program.

mtp_property_pure 

The behaviour of the method does not depend on any global/external state.

This mostly means that no waiting/reading of user input is performed, no global variables read, or pointers to memory visible outside of the function dereferenced. The result of the function solely depends on its arguments.

mtp_property_noreturn 

This method never returns.

The method may for example abort or exit the program or contain an infinite loop). GCC: attribute((noreturn)).

mtp_property_terminates 

The function is guaranteed not to end in an endless and to not abort the program.

mtp_property_nothrow 

This method cannot throw an exception.

GCC: attribute((nothrow)).

mtp_property_naked 

This method is naked.

GCC: attribute((naked)).

mtp_property_malloc 

This method returns newly allocate memory.

GCC: attribute((malloc)).

mtp_property_returns_twice 

This method can return more than once (typically setjmp).

GCC: attribute((returns_twice)).

mtp_property_private 

All method invocations are known and inside the current compilation unit, the backend can freely choose the calling convention.

mtp_property_always_inline 

Try to always inline this function, even if it seems nonprofitable.

mtp_property_noinline 

The function should not be inlined.

mtp_property_inline_recommended 

The programmer recommends to inline the function.

mtp_temporary 

Marker used by opt_funccall (really a hack)...

mtp_property_is_constructor 

marker used for oo analyses needing info whether method is constructor or not

Definition at line 224 of file firm_types.h.

Function Documentation

◆ get_method_additional_properties()

mtp_additional_properties get_method_additional_properties ( const ir_type method)

Returns the mask of the additional graph properties.

◆ get_method_calling_convention()

unsigned get_method_calling_convention ( const ir_type method)

Returns the calling convention of an entities graph.

◆ get_method_n_params()

size_t get_method_n_params ( const ir_type method)

Returns the number of parameters of this method.

◆ get_method_n_regparams()

unsigned get_method_n_regparams ( ir_type method)

Returns the number of registers parameters, 0 means default.

◆ get_method_n_ress()

size_t get_method_n_ress ( const ir_type method)

Returns the number of results of a method type.

◆ get_method_param_type()

ir_type* get_method_param_type ( const ir_type method,
size_t  pos 
)

Returns the type of the parameter at position pos of a method.

◆ get_method_res_type()

ir_type* get_method_res_type ( const ir_type method,
size_t  pos 
)

Returns the return type of a method type at position pos.

◆ is_Method_type()

int is_Method_type ( const ir_type method)

Returns true if a type is a method type.

◆ is_method_variadic()

int is_method_variadic ( ir_type const *  method)

Returns the variadicity of a method.

◆ new_type_method()

ir_type* new_type_method ( size_t  n_param,
size_t  n_res,
int  is_variadic,
unsigned  cc_mask,
mtp_additional_properties  property_mask 
)

Create a new method type.

Parameters
n_paramthe number of parameters
n_resthe number of results
is_variadicwhether the function is variadic
cc_maskthe calling convention
property_maskthe mask of the additional graph properties

The arrays for the parameter and result types are not populated by the constructor.

◆ set_method_param_type()

void set_method_param_type ( ir_type method,
size_t  pos,
ir_type tp 
)

Sets the type of the parameter at position pos of a method.

Note: does not change the corresponding parameter entities (if there are any)

◆ set_method_res_type()

void set_method_res_type ( ir_type method,
size_t  pos,
ir_type tp 
)

Sets the type of the result at position pos of a method.