- * ATTRIBUTES
- * member All entities belonging to this class. This are the fields
- * that can have any of the following types: type_class,
- * type_struct, type_union, type_array, type_enumeration,
- * type_pointer, type_primitive.
- * This is a dynamic list that can be grown with an "add_" function,
- * but not shrinked.
- * This is a dynamic list that can be grown with an "add_" function,
- * but not shrinked.
- * SOURCE
- */
-/* create a new type struct */
-type *new_type_struct (ident *name);
-
-/* manipulate private fields of struct */
-void add_struct_member (type *strct, entity *member);
-int get_struct_n_members (type *strct);
-entity *get_struct_member (type *strct, int pos);
-void set_struct_member (type *strct, int pos, entity *member);
-/* Finds member in the list of memberss and removees it */
-void remove_struct_member (type *strct, entity *member);
-
-/* typecheck */
-bool is_struct_type(type *strct);
-/*****/
-
-/****** type/method
- * NAME
- * Representation of a method type.
- * NOTE
- * 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 a optimization, as a change creates a new method
- * type. Therefore optimizations should allocated new method types.
- * The set_ routines are only for construction by a frontend.
- * ATTRIBUTES
- * n_params Number of parameters to the procedure.
- * A procedure in FIRM has only call by value parameters.
- *
- * param_type A list with the types of parameters. This list is ordered.
- * The nth type in this list corresponds to the nth element
- * in the parameter tuple that is a result of the start node.
- * (See ircons.h for more information.)
- *
- * n_res The number of results of the method. In general, procedures
- * have zero results, functions one.
- *
- * res_type A list with the types of parameters. This list is ordered.
- * The nth type in this list corresponds to the nth input to
- * Return nodes. (See ircons.h for more information.)
- * SOURCE
- */
-
-/* Create a new method type.
- N_param is the number of parameters, n_res the number of results.
- The arrays for the parameter and result types are not initialized by
- the constructor. */
-type *new_type_method (ident *name, int n_param, int n_res);
-
-/* manipulate private fields of method. */
-int get_method_n_params (type *method);
-type *get_method_param_type(type *method, int pos);
-void set_method_param_type(type *method, int pos, type* type);
-
-int get_method_n_ress (type *method);
-type *get_method_res_type(type *method, int pos);
-void set_method_res_type(type *method, int pos, type* type);
-
-/* typecheck */
-bool is_method_type (type *method);
-/*****/
-
-/****** type/union
- * NAME
- * Representation of a union type.
- * NOTE
+ * The following attributes are private to this type kind:
+ * - member: All entities belonging to this class. This are the fields
+ * that can have any of the following types: type_class,
+ * type_struct, type_union, type_array, type_enumeration,
+ * type_pointer, type_primitive.
+ * This is a dynamic list that can be grown with an "add_" function,
+ * but not shrinked.
+ * This is a dynamic list that can be grown with an "add_" function,
+ * but not shrinked.
+ */
+/** Creates a new type struct */
+ir_type *new_type_struct (ident *name);
+/** Creates a new type struct with debug information. */
+ir_type *new_d_type_struct (ident *name, dbg_info* db);
+
+/* --- manipulate private fields of struct --- */
+
+/** Adds the entity as member of the struct. */
+void add_struct_member (ir_type *strct, entity *member);
+
+/** Returns the number of members of this struct. */
+int get_struct_n_members (const ir_type *strct);
+
+/** Returns the member at position pos, 0 <= pos < n_member */
+entity *get_struct_member (const ir_type *strct, int pos);
+
+/** Returns index of member in strct, -1 if not contained. */
+int get_struct_member_index(const ir_type *strct, entity *member);
+
+/** Overwrites the member at position pos, 0 <= pos < n_member with
+ the passed entity. */
+void set_struct_member (ir_type *strct, int pos, entity *member);
+
+/** Finds member in the list of members and removes it. */
+void remove_struct_member (ir_type *strct, entity *member);
+
+/** Returns true if a type is a struct type. */
+int is_Struct_type(const ir_type *strct);
+
+/**
+ * @page method_type Representation of a method type
+ *
+ * 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 a optimization, as a change creates a new method
+ * type. Therefore optimizations should allocated new method types.
+ * The set_ routines are only for construction by a frontend.
+ *
+ * - n_params: Number of parameters to the procedure.
+ * A procedure in FIRM has only call by value parameters.
+ *
+ * - param_type: A list with the types of parameters. This list is ordered.
+ * The nth type in this list corresponds to the nth element
+ * in the parameter tuple that is a result of the start node.
+ * (See ircons.h for more information.)
+ *
+ * - value_param_ents
+ * A list of entities (whose owner is a struct private to the
+ * method type) that represent parameters passed by value.
+ *
+ * - n_res: The number of results of the method. In general, procedures
+ * have zero results, functions one.
+ *
+ * - res_type: A list with the types of parameters. This list is ordered.
+ * The nth type in this list corresponds to the nth input to
+ * Return nodes. (See ircons.h for more information.)
+ *
+ * - value_res_ents
+ * A list of entities (whose owner is a struct private to the
+ * method type) that represent results passed by value.
+ */
+
+/* These macros define the suffixes for the types and entities used
+ to represent value parameters / results. */
+#define VALUE_PARAMS_SUFFIX "val_param"
+#define VALUE_RESS_SUFFIX "val_res"
+
+/** Create a new method type.
+ *
+ * @param name the name (ident) of this type
+ * @param n_param the number of parameters
+ * @param n_res the number of results
+ *
+ * The arrays for the parameter and result types are not initialized by
+ * the constructor.
+ */
+ir_type *new_type_method (ident *name, int n_param, int n_res);
+
+/** Create a new method type with debug information.
+ *
+ * @param name the name (ident) of this type
+ * @param n_param the number of parameters
+ * @param n_res the number of results
+ * @param db user defined debug information
+ *
+ * The arrays for the parameter and result types are not initialized by
+ * the constructor.
+ */
+ir_type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db);
+
+/* -- manipulate private fields of method. -- */
+
+/** Returns the number of parameters of this method. */
+int get_method_n_params (const ir_type *method);
+
+/** Returns the type of the parameter at position pos of a method. */
+ir_type *get_method_param_type(ir_type *method, int pos);
+/** Sets the type of the parameter at position pos of a method.
+ Also changes the type in the pass-by-value representation by just
+ changing the type of the corresponding entity if the representation is constructed. */
+void set_method_param_type(ir_type *method, int pos, ir_type *tp);
+/** Returns an entity that represents the copied value argument. Only necessary
+ for compounds passed by value. This information is constructed only on demand. */
+entity *get_method_value_param_ent(ir_type *method, int pos);
+/**
+ * Returns a type that represents the copied value arguments.
+ */
+ir_type *get_method_value_param_type(const ir_type *method);
+
+/** Returns the number of results of a method type. */
+int get_method_n_ress (const ir_type *method);
+/** Returns the return type of a method type at position pos. */
+ir_type *get_method_res_type(ir_type *method, int pos);
+/** Sets the type of the result at position pos of a method.
+ Also changes the type in the pass-by-value representation by just
+ changing the type of the corresponding entity if the representation is constructed. */
+void set_method_res_type(ir_type *method, int pos, ir_type *tp);
+/** Returns an entity that represents the copied value result. Only necessary
+ for compounds passed by value. This information is constructed only on demand. */
+entity *get_method_value_res_ent(ir_type *method, int pos);
+
+/**
+ * Returns a type that represents the copied value results.
+ */
+ir_type *get_method_value_res_type(const ir_type *method);
+
+/**
+ * This enum flags the variadicity of methods (methods with a
+ * variable amount of arguments (e.g. C's printf). Default is
+ * non_variadic.
+ */
+typedef enum variadicity {
+ variadicity_non_variadic, /**< non variadic */
+ variadicity_variadic /**< variadic */
+} variadicity;
+
+/** Returns the null-terminated name of this variadicity. */
+const char *get_variadicity_name(variadicity vari);
+
+/** Returns the variadicity of a method. */
+variadicity get_method_variadicity(const ir_type *method);
+
+/** Sets the variadicity of a method. */
+void set_method_variadicity(ir_type *method, variadicity vari);
+
+/**
+ * Returns the first variadic parameter index of a type.
+ * If this index was NOT set, the index of the last parameter
+ * of the method type plus one is returned for variadic functions.
+ * Non-variadic function types always return -1 here.
+ */
+int get_method_first_variadic_param_index(const ir_type *method);
+
+/**
+ * Sets the first variadic parameter index. This allows to specify
+ * a complete call type (containing the type of all parameters)
+ * but still have the knowledge, which parameter must be passed as
+ * variadic one.
+ */
+void set_method_first_variadic_param_index(ir_type *method, int index);
+
+/**
+ * additional method type properties:
+ * Tell about special properties of a method type. Some
+ * of these may be discovered by analyses.
+ */
+typedef enum {
+ mtp_no_property = 0x00000000, /**< no additional properties, default */
+ mtp_property_const = 0x00000001, /**< This method did not access memory and calculates
+ its return values solely from its parameters.
+ GCC: __attribute__((const)). */
+ mtp_property_pure = 0x00000002, /**< This method did NOT write to memory and calculates
+ its return values solely form its parameters and
+ the memory they points to (or global vars).
+ GCC: __attribute__((pure)). */
+ mtp_property_noreturn = 0x00000004, /**< This method did not return due to an aborting system
+ call.
+ GCC: __attribute__((noreturn)). */
+ mtp_property_nothrow = 0x00000008, /**< This method cannot throw an exception.
+ GCC: __attribute__((nothrow)). */
+ mtp_property_naked = 0x00000010, /**< This method is naked.
+ GCC: __attribute__((naked)). */
+ mtp_property_malloc = 0x00000020, /**< This method returns newly allocate memory.
+ GCC: __attribute__((malloc)). */
+ mtp_property_intrinsic = 0x00000040, /**< This method is intrinsic. It is expected that
+ a lowering phase will remove all calls to it. */
+ mtp_property_inherited = 0x40000000 /**< used only in irg's, means property is inherited
+ from type. */
+} mtp_additional_property;
+
+/** Returns the mask of the additional graph properties. */
+unsigned get_method_additional_properties(const ir_type *method);
+
+/** Sets the mask of the additional graph properties. */
+void set_method_additional_properties(ir_type *method, unsigned property_mask);
+
+/** Sets one additional graph property. */
+void set_method_additional_property(ir_type *method, mtp_additional_property flag);
+
+/**
+ * calling conventions: lower 24 bits are the number of register parameters,
+ * upper 8 encode the calling conventions
+ */
+typedef enum {
+ cc_reg_param = 0x01000000, /**< Transmit parameters in registers, else the stack is used.
+ This flag may be set as default on some architectures. */
+ cc_last_on_top = 0x02000000, /**< The last non-register parameter is transmitted on top of
+ the stack. This is equivalent to the stdcall or pascal
+ calling convention. If this flag is not set, the first
+ non-register parameter is used (cdecl calling convention) */
+ cc_callee_clear_stk = 0x04000000, /**< The callee clears the stack. This forbids variadic
+ function calls (stdcall). */
+ cc_this_call = 0x08000000, /**< The first parameter is a this pointer and is transmitted
+ in a special way. */
+
+
+ cc_bits = (0xFF << 24) /**< the calling convention bits */
+} calling_convention;
+
+/* some often used cases: made as defines for firmjni */
+/** cdecl calling convention */
+#define cc_cdecl_set (0)
+/** stdcall calling convention */
+#define cc_stdcall_set cc_callee_clear_stk
+/** fastcall calling convention */
+#define cc_fastcall_set (cc_reg_param|cc_callee_clear_stk)
+
+/** return the default calling convention for method types */
+unsigned get_default_cc_mask(void);
+
+/**
+ * check for the CDECL calling convention
+ */
+#define IS_CDECL(cc_mask) (((cc_mask) & cc_bits) == cc_cdecl_set)
+
+/**
+ * check for the STDCALL calling convention
+ */
+#define IS_STDCALL(cc_mask) (((cc_mask) & cc_bits) == cc_stdcall_set)
+
+/**
+ * check for the FASTCALL calling convention
+ */
+#define IS_FASTCALL(cc_mask) (((cc_mask) & cc_bits) == cc_fastcall_set)
+
+/**
+ * set the CDECL convention bits
+ */
+#define SET_CDECL(cc_mask) (((cc_mask) & ~cc_bits) | cc_cdecl_set)
+
+/**
+ * set the STDCALL convention bits
+ */
+#define SET_STDCALL(cc_mask) (((cc_mask) & ~cc_bits) | cc_stdcall_set)
+
+/**
+ * set the FASTCALL convention bits
+ */
+#define SET_FASTCALL(cc_mask) (((cc_mask) & ~cc_bits) | cc_fastcall_set)
+
+/** Returns the calling convention of an entities graph. */
+unsigned get_method_calling_convention(const ir_type *method);
+
+/** Sets the calling convention of an entities graph. */
+void set_method_calling_convention(ir_type *method, unsigned cc_mask);
+
+/** Returns the number of registers parameters, 0 means default. */
+unsigned get_method_n_regparams(ir_type *method);
+
+/** Sets the number of registers parameters, 0 means default. */
+void set_method_n_regparams(ir_type *method, unsigned n_regs);
+
+/** Returns true if a type is a method type. */
+int is_Method_type (const ir_type *method);
+
+/**
+ * @page union_type Representation of a union (variant) type.
+ *