Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
c06a5840
Commit
c06a5840
authored
Aug 17, 2009
by
Michael Beck
Browse files
- add more pass constructors
[r26376]
parent
856c2a59
Changes
8
Hide whitespace changes
Inline
Side-by-side
include/libfirm/irpass.h
View file @
c06a5840
/*
* Copyright (C) 1995-200
8
University of Karlsruhe. All right reserved.
* Copyright (C) 1995-200
9
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
...
...
@@ -172,4 +172,19 @@ ir_graph_pass_t *def_graph_pass_constructor(
ir_prog_pass_t
*
def_prog_pass
(
const
char
*
name
,
void
(
*
function
)(
void
));
/**
* Creates an ir_prog pass for running void function().
* Uses the default verifier and dumper.
* The pass returns always 0.
*
* @param memory if non-NULL, an already allocated ir_prog_pass_t
* @param name the name of this pass
* @param function the function to run
*
* @return the newly created ir_graph pass
*/
ir_prog_pass_t
*
def_prog_pass_constructor
(
ir_prog_pass_t
*
memory
,
const
char
*
name
,
void
(
*
function
)(
ir_prog
*
irp
,
void
*
context
));
#endif
include/libfirm/lowering.h
View file @
c06a5840
...
...
@@ -159,6 +159,17 @@ void lower_CopyB(ir_graph *irg, unsigned max_size, unsigned native_mode_bytes);
*/
void
lower_switch
(
ir_graph
*
irg
,
unsigned
spare_size
);
/**
* Creates an ir_graph pass for lower_switch().
*
* @param name the name of this pass or NULL
* @param spare_size Allowed spare size for table switches in machine words.
* (Default in edgfe: 128)
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t
*
lower_switch_pass
(
const
char
*
name
,
unsigned
spare_size
);
/**
* A callback type for creating an intrinsic entity for a given opcode.
*
...
...
@@ -190,9 +201,21 @@ typedef struct _lwrdw_param_t {
/**
* Lower all double word operations.
*
* @param param parameter for lowering
*/
void
lower_dw_ops
(
const
lwrdw_param_t
*
param
);
/**
* Creates an ir_prog pass for lower_dw_ops().
*
* @param name the name of this pass or NULL
* @param param parameter for lowering
*
* @return the newly created ir_prog pass
*/
ir_prog_pass_t
*
lower_dw_ops_pass
(
const
char
*
name
,
const
lwrdw_param_t
*
param
);
/**
* Default implementation. Context is unused.
*/
...
...
@@ -231,7 +254,7 @@ ir_graph_pass_t *lower_highlevel_graph_pass(const char *name, int lower_bitfield
* Handle bit fields by added And/Or calculations.
* Lowers all graphs.
*
* @Note: There is NO lowering o
b
objects oriented types. This is highly compiler
* @Note: There is NO lowering o
f
objects oriented types. This is highly compiler
* and ABI specific and should be placed directly in the compiler.
*/
void
lower_highlevel
(
int
lower_bitfields
);
...
...
@@ -246,7 +269,7 @@ void lower_const_code(void);
*
* @param name the name of this pass or NULL
*
* @return the newly created ir_
graph
pass
* @return the newly created ir_
prog
pass
*/
ir_prog_pass_t
*
lower_const_code_pass
(
const
char
*
name
);
...
...
@@ -266,11 +289,22 @@ typedef struct lower_mode_b_config_t {
*
* Example: Psi(a < 0, 1, 0) => a >> 31
*
* @param irg
the firm graph to lower
* @param config
configuration for mode_b lowerer
* @param irg the firm graph to lower
* @param config configuration for mode_b lowerer
*/
void
ir_lower_mode_b
(
ir_graph
*
irg
,
const
lower_mode_b_config_t
*
config
);
/**
* Creates an ir_graph pass for ir_lower_mode_b().
*
* @param name the name of this pass or NULL
* @param config configuration for mode_b lowerer
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t
*
ir_lower_mode_b_pass
(
const
char
*
name
,
const
lower_mode_b_config_t
*
config
);
/**
* An intrinsic mapper function.
*
...
...
ir/ir/irpass.c
View file @
c06a5840
...
...
@@ -433,3 +433,22 @@ ir_prog_pass_t *def_prog_pass(
return
pass
;
}
/* def_prog_pass */
/* Creates an ir_prog pass for running void function(void). */
ir_prog_pass_t
*
def_prog_pass_constructor
(
ir_prog_pass_t
*
pass
,
const
char
*
name
,
void
(
*
function
)(
ir_prog
*
irp
,
void
*
context
))
{
if
(
pass
==
NULL
)
pass
=
XMALLOCZ
(
ir_prog_pass_t
);
pass
->
kind
=
k_ir_prog_pass
;
pass
->
run_on_irprog
=
function
;
pass
->
context
=
pass
;
pass
->
name
=
name
;
INIT_LIST_HEAD
(
&
pass
->
list
);
return
pass
;
}
/* def_prog_pass_constructor */
ir/lower/lower_dw.c
View file @
c06a5840
...
...
@@ -52,6 +52,7 @@
#include
"pdeq.h"
#include
"irdump.h"
#include
"array_t.h"
#include
"irpass_t.h"
/** A map from mode to a primitive type. */
static
pmap
*
prim_types
;
...
...
@@ -2685,6 +2686,30 @@ void lower_dw_ops(const lwrdw_param_t *param)
current_ir_graph
=
rem
;
}
/* lower_dw_ops */
struct
pass_t
{
ir_prog_pass_t
pass
;
const
lwrdw_param_t
*
param
;
};
/**
* Creates a wrapper around lower_dw_ops().
*/
static
int
pass_wrapper
(
ir_prog
*
irp
,
void
*
context
)
{
struct
pass_t
*
pass
=
context
;
(
void
)
irp
;
lower_dw_ops
(
pass
->
param
);
return
0
;
}
/* pass_wrapper */
ir_prog_pass_t
*
lower_dw_ops_pass
(
const
char
*
name
,
const
lwrdw_param_t
*
param
)
{
struct
pass_t
*
pass
=
XMALLOCZ
(
struct
pass_t
);
pass
->
param
=
param
;
return
def_prog_pass_constructor
(
&
pass
->
pass
,
name
?
name
:
"lower_dw"
,
pass_wrapper
);
}
/* lower_dw_ops_pass */
/* Default implementation. */
ir_entity
*
def_create_intrinsic_fkt
(
ir_type
*
method
,
const
ir_op
*
op
,
const
ir_mode
*
imode
,
const
ir_mode
*
omode
,
...
...
ir/lower/lower_intrinsics.c
View file @
c06a5840
...
...
@@ -193,19 +193,12 @@ ir_prog_pass_t *lower_intrinsics_pass(
{
struct
pass_t
*
pass
=
xmalloc
(
sizeof
(
*
pass
)
+
(
length
-
1
)
*
sizeof
(
pass
->
list
[
0
]));
memset
(
&
pass
->
pass
,
0
,
sizeof
(
pass
->
pass
));
pass
->
pass
.
kind
=
k_ir_prog_pass
;
pass
->
pass
.
run_on_irprog
=
pass_wrapper
;
pass
->
pass
.
context
=
pass
;
pass
->
pass
.
name
=
name
?
name
:
"lower_intrinsics"
;
INIT_LIST_HEAD
(
&
pass
->
pass
.
list
);
memcpy
(
pass
->
list
,
list
,
sizeof
(
list
[
0
])
*
length
);
pass
->
length
=
length
;
pass
->
part_block_used
=
part_block_used
;
return
&
pass
->
pass
;
return
def_prog_pass_constructor
(
&
pass
->
pass
,
name
?
name
:
"lower_intrinsics"
,
pass_wrapper
);
}
/* lower_intrinsics_pass*/
/**
...
...
ir/lower/lower_mode_b.c
View file @
c06a5840
...
...
@@ -41,6 +41,7 @@
#include
"error.h"
#include
"lowering.h"
#include
"pdeq.h"
#include
"irpass_t.h"
static
lower_mode_b_config_t
config
;
static
ir_type
*
lowered_type
=
NULL
;
...
...
@@ -417,3 +418,27 @@ void ir_lower_mode_b(ir_graph *irg, const lower_mode_b_config_t *nconfig)
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
}
struct
pass_t
{
ir_graph_pass_t
pass
;
const
lower_mode_b_config_t
*
config
;
};
/**
* Wrapper to run ir_lower_mode_b() as an ir_graph pass
*/
static
int
pass_wrapper
(
ir_graph
*
irg
,
void
*
context
)
{
struct
pass_t
*
pass
=
context
;
ir_lower_mode_b
(
irg
,
pass
->
config
);
return
0
;
}
ir_graph_pass_t
*
ir_lower_mode_b_pass
(
const
char
*
name
,
const
lower_mode_b_config_t
*
config
)
{
struct
pass_t
*
pass
=
XMALLOCZ
(
struct
pass_t
);
pass
->
config
=
config
;
return
def_graph_pass_constructor
(
&
pass
->
pass
,
name
?
name
:
"lower_mode_b"
,
pass_wrapper
);
}
ir/lower/lower_switch.c
View file @
c06a5840
...
...
@@ -34,6 +34,7 @@
#include
"irgwalk.h"
#include
"irnode_t.h"
#include
"irouts.h"
#include
"irpass_t.h"
#define foreach_out_irn(irn, i, outirn) for(i = get_irn_n_outs(irn) - 1;\
i >= 0 && (outirn = get_irn_out(irn, i)); --i)
...
...
@@ -279,3 +280,27 @@ void lower_switch(ir_graph *irg, unsigned spare_size)
}
current_ir_graph
=
rem
;
}
struct
pass_t
{
ir_graph_pass_t
pass
;
unsigned
spare_size
;
};
/**
* Wrapper for running lower_switch() as a pass.
*/
static
int
pass_wrapper
(
ir_graph
*
irg
,
void
*
context
)
{
struct
pass_t
*
pass
=
context
;
lower_switch
(
irg
,
pass
->
spare_size
);
return
0
;
}
/* creates a pass for lower_switch */
ir_graph_pass_t
*
lower_switch_pass
(
const
char
*
name
,
unsigned
spare_size
)
{
struct
pass_t
*
pass
=
XMALLOCZ
(
struct
pass_t
);
pass
->
spare_size
=
spare_size
;
return
def_graph_pass_constructor
(
&
pass
->
pass
,
name
?
name
:
"lower_switch"
,
pass_wrapper
);
}
ir/opt/funccall.c
View file @
c06a5840
...
...
@@ -1097,17 +1097,11 @@ ir_prog_pass_t *optimize_funccalls_pass(
const
char
*
name
,
int
force_run
,
check_alloc_entity_func
callback
)
{
struct
pass_t
*
pass
=
xmalloc
(
sizeof
(
*
pass
));
pass
->
pass
.
kind
=
k_ir_prog_pass
;
pass
->
pass
.
run_on_irprog
=
pass_wrapper
;
pass
->
pass
.
context
=
pass
;
pass
->
pass
.
name
=
name
?
name
:
"funccalls"
;
INIT_LIST_HEAD
(
&
pass
->
pass
.
list
);
struct
pass_t
*
pass
=
XMALLOCZ
(
struct
pass_t
);
pass
->
force_run
=
force_run
;
pass
->
callback
=
callback
;
return
&
pass
->
pass
;
return
def_prog_pass_constructor
(
&
pass
->
pass
,
name
?
name
:
"funccall"
,
pass_wrapper
);
}
/* optimize_funccalls_pass */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment