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 { ...@@ -217,7 +217,6 @@ typedef struct {
ir_mode *mode; /**< The mode of the constraint. */ ir_mode *mode; /**< The mode of the constraint. */
} ir_asm_constraint; } ir_asm_constraint;
/** Supported libFirm builtins. */
/** Supported libFirm builtins. */ /** Supported libFirm builtins. */
typedef enum { typedef enum {
ir_bk_trap, /**< GCC __builtin_trap(): insert trap */ ir_bk_trap, /**< GCC __builtin_trap(): insert trap */
......
...@@ -164,6 +164,7 @@ libfirm_la_SOURCES = \ ...@@ -164,6 +164,7 @@ libfirm_la_SOURCES = \
ir/irgwalk_blk.c \ ir/irgwalk_blk.c \
ir/irgwalk.c \ ir/irgwalk.c \
ir/irhooks.c \ ir/irhooks.c \
ir/irio.c \
ir/irlinkednodemap.c \ ir/irlinkednodemap.c \
ir/irlinkednodeset.c \ ir/irlinkednodeset.c \
ir/irmode.c \ ir/irmode.c \
......
...@@ -54,17 +54,18 @@ typedef struct io_env ...@@ -54,17 +54,18 @@ typedef struct io_env
typedef enum typetag_t typedef enum typetag_t
{ {
tt_iro,
tt_tpo,
tt_align, tt_align,
tt_allocation, tt_allocation,
tt_builtin,
tt_initializer,
tt_iro,
tt_peculiarity, tt_peculiarity,
tt_pin_state, tt_pin_state,
tt_tpo,
tt_type_state, tt_type_state,
tt_variability, tt_variability,
tt_visibility, tt_visibility,
tt_volatility, tt_volatility
tt_initializer
} typetag_t; } typetag_t;
typedef struct symbol_t typedef struct symbol_t
...@@ -120,7 +121,7 @@ static void symtbl_init(void) ...@@ -120,7 +121,7 @@ static void symtbl_init(void)
if(symtbl != NULL) if(symtbl != NULL)
return; return;
symtbl = new_set(symbol_cmp, 32); symtbl = new_set(symbol_cmp, 256);
#define INSERT(s, tt, cod) \ #define INSERT(s, tt, cod) \
key.str = (s); \ key.str = (s); \
...@@ -177,6 +178,21 @@ static void symtbl_init(void) ...@@ -177,6 +178,21 @@ static void symtbl_init(void)
INSERTENUM(tt_initializer, IR_INITIALIZER_NULL); INSERTENUM(tt_initializer, IR_INITIALIZER_NULL);
INSERTENUM(tt_initializer, IR_INITIALIZER_COMPOUND); 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 INSERTENUM
#undef INSERT #undef INSERT
} }
...@@ -257,10 +273,17 @@ static void write_align(io_env_t *env, ir_node *irn) ...@@ -257,10 +273,17 @@ static void write_align(io_env_t *env, ir_node *irn)
fputc(' ', env->file); 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) static void write_initializer(io_env_t *env, ir_initializer_t *ini)
{ {
FILE *f = env->file; FILE *f = env->file;
ir_initializer_kind_t ini_kind = get_initializer_kind(ini); ir_initializer_kind_t ini_kind = get_initializer_kind(ini);
fputs(get_initializer_kind_name(ini_kind), f); fputs(get_initializer_kind_name(ini_kind), f);
fputc(' ', f); fputc(' ', f);
...@@ -769,12 +792,14 @@ static const char *get_typetag_name(typetag_t typetag) ...@@ -769,12 +792,14 @@ static const char *get_typetag_name(typetag_t typetag)
{ {
switch(typetag) switch(typetag)
{ {
case tt_iro: return "opcode";
case tt_tpo: return "type";
case tt_align: return "align"; case tt_align: return "align";
case tt_allocation: return "allocation"; 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_peculiarity: return "peculiarity";
case tt_pin_state: return "pin state"; case tt_pin_state: return "pin state";
case tt_tpo: return "type";
case tt_type_state: return "type state"; case tt_type_state: return "type state";
case tt_variability: return "variability"; case tt_variability: return "variability";
case tt_visibility: return "visibility"; case tt_visibility: return "visibility";
...@@ -806,6 +831,7 @@ static unsigned read_enum(io_env_t *env, typetag_t typetag) ...@@ -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_visibility(env) ((ir_visibility) read_enum(env, tt_visibility))
#define read_volatility(env) ((ir_volatility) read_enum(env, tt_volatility)) #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_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) static ir_cons_flags get_cons_flags(io_env_t *env)
{ {
......
...@@ -1426,7 +1426,7 @@ set_Builtin_type(ir_node *node, ir_type *tp) { ...@@ -1426,7 +1426,7 @@ set_Builtin_type(ir_node *node, ir_type *tp) {
/* Returns a human readable string for the ir_builtin_kind. */ /* Returns a human readable string for the ir_builtin_kind. */
const char *get_builtin_kind_name(ir_builtin_kind 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) { switch (kind) {
X(ir_bk_trap); X(ir_bk_trap);
X(ir_bk_debugbreak); X(ir_bk_debugbreak);
......
...@@ -59,6 +59,9 @@ def get_io_type(type, attrname, nodename): ...@@ -59,6 +59,9 @@ def get_io_type(type, attrname, nodename):
elif type == "op_pin_state": elif type == "op_pin_state":
importcmd = "op_pin_state %s = read_pin_state(env);" % attrname importcmd = "op_pin_state %s = read_pin_state(env);" % attrname
exportcmd = "write_pin_state(env, irn);" 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: else:
print "UNKNOWN TYPE: %s" % type print "UNKNOWN TYPE: %s" % type
importcmd = """// BAD: %s %s importcmd = """// BAD: %s %s
...@@ -143,6 +146,13 @@ def preprocess_node(nodename, node): ...@@ -143,6 +146,13 @@ def preprocess_node(nodename, node):
arguments.append("prednodes[%i]" % i) arguments.append("prednodes[%i]" % i)
i += 1 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": if node["arity"] == "variable" or node["arity"] == "dynamic":
arguments.append("numpreds - %i" % (i + 1)) arguments.append("numpreds - %i" % (i + 1))
arguments.append("prednodes + %i" % i) arguments.append("prednodes + %i" % i)
...@@ -151,6 +161,8 @@ def preprocess_node(nodename, node): ...@@ -151,6 +161,8 @@ def preprocess_node(nodename, node):
arguments.append("mode") arguments.append("mode")
for attr in node["attrs"]: for attr in node["attrs"]:
if nodename == "Builtin" and attr["name"] == "kind":
continue
prepare_attr(nodename, attr) prepare_attr(nodename, attr)
arguments.append(attr["name"]) arguments.append(attr["name"])
......
...@@ -101,6 +101,22 @@ Call = dict( ...@@ -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( binop = dict(
abstract = True, abstract = True,
ins = [ "left", "right" ] 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