Commit 2457c993 authored by Moritz Kroll's avatar Moritz Kroll
Browse files

irio: Added support for Builtin nodes

[r25524]
parent 5cfbace4
......@@ -217,7 +217,6 @@ typedef struct {
ir_mode *mode; /**< The mode of the constraint. */
} ir_asm_constraint;
/** Supported libFirm builtins. */
/** Supported libFirm builtins. */
typedef enum {
ir_bk_trap, /**< GCC __builtin_trap(): insert trap */
......
......@@ -164,6 +164,7 @@ libfirm_la_SOURCES = \
ir/irgwalk_blk.c \
ir/irgwalk.c \
ir/irhooks.c \
ir/irio.c \
ir/irlinkednodemap.c \
ir/irlinkednodeset.c \
ir/irmode.c \
......
......@@ -54,17 +54,18 @@ typedef struct io_env
typedef enum typetag_t
{
tt_iro,
tt_tpo,
tt_align,
tt_allocation,
tt_builtin,
tt_initializer,
tt_iro,
tt_peculiarity,
tt_pin_state,
tt_tpo,
tt_type_state,
tt_variability,
tt_visibility,
tt_volatility,
tt_initializer
tt_volatility
} typetag_t;
typedef struct symbol_t
......@@ -120,7 +121,7 @@ static void symtbl_init(void)
if(symtbl != NULL)
return;
symtbl = new_set(symbol_cmp, 32);
symtbl = new_set(symbol_cmp, 256);
#define INSERT(s, tt, cod) \
key.str = (s); \
......@@ -177,6 +178,21 @@ static void symtbl_init(void)
INSERTENUM(tt_initializer, IR_INITIALIZER_NULL);
INSERTENUM(tt_initializer, IR_INITIALIZER_COMPOUND);
INSERTENUM(tt_builtin, ir_bk_trap);
INSERTENUM(tt_builtin, ir_bk_debugbreak);
INSERTENUM(tt_builtin, ir_bk_return_address);
INSERTENUM(tt_builtin, ir_bk_frame_addess);
INSERTENUM(tt_builtin, ir_bk_prefetch);
INSERTENUM(tt_builtin, ir_bk_ffs);
INSERTENUM(tt_builtin, ir_bk_clz);
INSERTENUM(tt_builtin, ir_bk_ctz);
INSERTENUM(tt_builtin, ir_bk_popcount);
INSERTENUM(tt_builtin, ir_bk_parity);
INSERTENUM(tt_builtin, ir_bk_bswap);
INSERTENUM(tt_builtin, ir_bk_inport);
INSERTENUM(tt_builtin, ir_bk_outport);
INSERTENUM(tt_builtin, ir_bk_inner_trampoline);
#undef INSERTENUM
#undef INSERT
}
......@@ -257,10 +273,17 @@ static void write_align(io_env_t *env, ir_node *irn)
fputc(' ', env->file);
}
static void write_builtin_kind(io_env_t *env, ir_node *irn)
{
fputs(get_builtin_kind_name(get_Builtin_kind(irn)), env->file);
fputc(' ', env->file);
}
static void write_initializer(io_env_t *env, ir_initializer_t *ini)
{
FILE *f = env->file;
ir_initializer_kind_t ini_kind = get_initializer_kind(ini);
fputs(get_initializer_kind_name(ini_kind), f);
fputc(' ', f);
......@@ -769,12 +792,14 @@ static const char *get_typetag_name(typetag_t typetag)
{
switch(typetag)
{
case tt_iro: return "opcode";
case tt_tpo: return "type";
case tt_align: return "align";
case tt_allocation: return "allocation";
case tt_builtin: return "builtin kind";
case tt_initializer: return "initializer kind";
case tt_iro: return "opcode";
case tt_peculiarity: return "peculiarity";
case tt_pin_state: return "pin state";
case tt_tpo: return "type";
case tt_type_state: return "type state";
case tt_variability: return "variability";
case tt_visibility: return "visibility";
......@@ -806,6 +831,7 @@ static unsigned read_enum(io_env_t *env, typetag_t typetag)
#define read_visibility(env) ((ir_visibility) read_enum(env, tt_visibility))
#define read_volatility(env) ((ir_volatility) read_enum(env, tt_volatility))
#define read_initializer_kind(env) ((ir_initializer_kind_t) read_enum(env, tt_initializer))
#define read_builtin_kind(env) ((ir_builtin_kind) read_enum(env, tt_builtin))
static ir_cons_flags get_cons_flags(io_env_t *env)
{
......
......@@ -1426,7 +1426,7 @@ set_Builtin_type(ir_node *node, ir_type *tp) {
/* Returns a human readable string for the ir_builtin_kind. */
const char *get_builtin_kind_name(ir_builtin_kind kind) {
#define X(a) case a: return #a + 6;
#define X(a) case a: return #a;
switch (kind) {
X(ir_bk_trap);
X(ir_bk_debugbreak);
......
......@@ -59,6 +59,9 @@ def get_io_type(type, attrname, nodename):
elif type == "op_pin_state":
importcmd = "op_pin_state %s = read_pin_state(env);" % attrname
exportcmd = "write_pin_state(env, irn);"
elif type == "ir_builtin_kind":
importcmd = "ir_builtin_kind %s = read_builtin_kind(env);" % attrname
exportcmd = "write_builtin_kind(env, irn);"
else:
print "UNKNOWN TYPE: %s" % type
importcmd = """// BAD: %s %s
......@@ -143,6 +146,13 @@ def preprocess_node(nodename, node):
arguments.append("prednodes[%i]" % i)
i += 1
# Special case for Builtin...
if nodename == "Builtin":
for attr in node["attrs"]:
if attr["name"] == "kind":
prepare_attr(nodename, attr)
arguments.append(attr["name"])
if node["arity"] == "variable" or node["arity"] == "dynamic":
arguments.append("numpreds - %i" % (i + 1))
arguments.append("prednodes + %i" % i)
......@@ -151,6 +161,8 @@ def preprocess_node(nodename, node):
arguments.append("mode")
for attr in node["attrs"]:
if nodename == "Builtin" and attr["name"] == "kind":
continue
prepare_attr(nodename, attr)
arguments.append(attr["name"])
......
......@@ -101,6 +101,22 @@ Call = dict(
]
),
Builtin = dict(
ins = [ "mem" ],
arity = "variable",
outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
attrs = [
dict(
type = "ir_builtin_kind",
name = "kind"
),
dict(
type = "ir_type*",
name = "type"
)
]
),
binop = dict(
abstract = True,
ins = [ "left", "right" ]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment