libFirm
irarch.h File Reference

Some machine dependent optimizations. More...

#include "firm_types.h"
#include "begin.h"
#include "end.h"

Go to the source code of this file.

Data Structures

struct  ir_settings_arch_dep_t
 A parameter structure that drives the machine dependent Firm optimizations. More...

Typedefs

typedef int(* evaluate_costs_func )(insn_kind kind, const ir_mode *mode, ir_tarval *tv)
 A Callback for evaluating the costs of an instruction.
typedef const
ir_settings_arch_dep_t *(* 
arch_dep_params_factory_t )(void)
 A factory function, that provides architecture parameters for machine dependent optimizations.

Enumerations

enum  insn_kind {
  LEA, SHIFT, SUB, ADD,
  ZERO, MUL, ROOT
}
 The Multiplication replacement can consist of the following instructions. More...
enum  arch_dep_opts_t { arch_dep_none = 0, arch_dep_mul_to_shift = 1, arch_dep_div_by_const = 2, arch_dep_mod_by_const = 4 }
 Optimization flags. More...

Functions

void arch_dep_set_opts (arch_dep_opts_t opts)
 Sets the optimizations that shall be applied.
ir_nodearch_dep_replace_mul_with_shifts (ir_node *irn)
 Replaces Muls with Lea/Shifts/Add/Subs if these have smaller costs than the original multiplication.
ir_nodearch_dep_replace_div_by_const (ir_node *irn)
 Replaces Divs with Shifts and Add/Subs and Mulh.
ir_nodearch_dep_replace_mod_by_const (ir_node *irn)
 Replaces Mods with Shifts and Add/Subs and Mulh.

Detailed Description

Some machine dependent optimizations.

Date
1.10.2004
Author
Sebastian Hack

Definition in file irarch.h.

Typedef Documentation

typedef const ir_settings_arch_dep_t*(* arch_dep_params_factory_t)(void)

A factory function, that provides architecture parameters for machine dependent optimizations.

Definition at line 80 of file irarch.h.

typedef int(* evaluate_costs_func)(insn_kind kind, const ir_mode *mode, ir_tarval *tv)

A Callback for evaluating the costs of an instruction.

Parameters
kindthe instruction
modethe mode of the instruction
tvfor MUL instruction, the multiplication constant
Returns
the costs of this instruction

Definition at line 54 of file irarch.h.

Enumeration Type Documentation

Optimization flags.

Enumerator:
arch_dep_mul_to_shift 

optimize Mul into Shift/Add/Sub

arch_dep_div_by_const 

optimize Div into Shift/Add/Mulh

arch_dep_mod_by_const 

optimize Mod into Shift/Add/Mulh

Definition at line 85 of file irarch.h.

enum insn_kind

The Multiplication replacement can consist of the following instructions.

Enumerator:
LEA 

the LEA instruction

SHIFT 

the SHIFT instruction

SUB 

the SUB instruction

ADD 

the ADD instruction

ZERO 

creates a ZERO constant

MUL 

the original MUL instruction

ROOT 

the ROOT value that is multiplied

Definition at line 35 of file irarch.h.

Function Documentation

ir_node* arch_dep_replace_div_by_const ( ir_node irn)

Replaces Divs with Shifts and Add/Subs and Mulh.

This function is driven by the 3 parameters:

  • allow_mulhu
  • allow_mulhs
  • max_bits_for_mulh

If irn is a Div with a Const, the constant is inspected if it meets the requirements of the variables stated above. If a Shl/Add/Sub/Mulh sequence can be generated that meets these requirements, this expression is returned. In each other case irn is returned unmodified.

Parameters
irnThe Firm node to inspect.
Returns
A replacement expression for irn.
ir_node* arch_dep_replace_mod_by_const ( ir_node irn)

Replaces Mods with Shifts and Add/Subs and Mulh.

This function is driven by the 3 parameters:

  • allow_mulhu
  • allow_mulhs
  • max_bits_for_mulh

If irn is a Mod with a Const, the constant is inspected if it meets the requirements of the variables stated above. If a Shl/Add/Sub/Mulh sequence can be generated that meets these requirements, this expression is returned. In each other case irn is returned unmodified.

Parameters
irnThe Firm node to inspect.
Returns
A replacement expression for irn.
ir_node* arch_dep_replace_mul_with_shifts ( ir_node irn)

Replaces Muls with Lea/Shifts/Add/Subs if these have smaller costs than the original multiplication.

Parameters
irnThe Firm node to inspect.
Returns
A replacement expression for irn.
void arch_dep_set_opts ( arch_dep_opts_t  opts)

Sets the optimizations that shall be applied.

Parameters
optsAn optimization bit mask.