summaryrefslogtreecommitdiffhomepage
path: root/ir/lower
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-01-04 20:12:21 +0100
committerMatthias Braun <matze@braunis.de>2017-02-20 04:48:18 +0100
commit1ffc842f8bb13ed098eeaf2382ba473f9e154466 (patch)
treecd4c1c9ca57400975db74b7212ac237166359704 /ir/lower
parent845e655dac11bc5eba82b9fc6d36a6f4fec23eb6 (diff)
Rework target initialization and query
- Moves machine triple handling code form cparser into libfirm - Create new APIs to set the target and query information about it - Move backend_params into the new target API - Backends initialize ir_target instead of backend_params now - Add new API to get information about the target platform: - Mangle a name for the target platform (and remove compilerlib mangling callback) - Can query size and alignment of basic C types for the platform - Move some constant target information into arch_isa_if_t (we move it to target_info_t later when we realize it needs to be dynamic) - Redo backend initialization. Examples: Simple case: Initialize for host: ir_init(); Complex case: cross-compile to sparc with PIC enabled: ir_init_library(); ir_target_set("sparc-leon-linux-gnu"); ir_target_option("pic"); ir_target_init();
Diffstat (limited to 'ir/lower')
-rw-r--r--ir/lower/lower_builtins.c8
-rw-r--r--ir/lower/lower_calls.c1
-rw-r--r--ir/lower/lower_copyb.c10
-rw-r--r--ir/lower/lower_dw.c50
-rw-r--r--ir/lower/lower_intrinsics.c6
-rw-r--r--ir/lower/lower_softfloat.c7
6 files changed, 39 insertions, 43 deletions
diff --git a/ir/lower/lower_builtins.c b/ir/lower/lower_builtins.c
index f60953c..57f1b53 100644
--- a/ir/lower/lower_builtins.c
+++ b/ir/lower/lower_builtins.c
@@ -11,7 +11,6 @@
#include "lower_builtins.h"
#include "adt/pmap.h"
-#include "be.h"
#include "ircons_t.h"
#include "irgmod.h"
#include "irgwalk.h"
@@ -19,6 +18,7 @@
#include "iroptimize.h"
#include "irprog_t.h"
#include "panic.h"
+#include "target_t.h"
#include "util.h"
#include <stdbool.h>
#include <stdlib.h>
@@ -73,9 +73,8 @@ static void widen_builtin(ir_node *node)
ir_type *arg1 = get_method_param_type(mtp, 0);
// Nothing to do, if argument size is at least machine size.
- if (8 * get_type_size(arg1) >= be_get_machine_size()) {
+ if (get_type_size(arg1) >= ir_target_pointer_size())
return;
- }
// Only touch builtins with no 32-bit version.
ir_builtin_kind kind = get_Builtin_kind(node);
@@ -113,7 +112,8 @@ static void replace_with_call(ir_node *node)
ir_type *const arg1 = get_method_param_type(mtp, 0);
char const *const machmode = get_gcc_machmode(arg1);
ident *const id = new_id_fmt("__%s%s2", name, machmode);
- ir_entity *const entity = create_compilerlib_entity(id, mtp);
+ ir_entity *const entity
+ = create_compilerlib_entity(get_id_str(id), mtp);
dbg_info *const dbgi = get_irn_dbg_info(node);
ir_node *const block = get_nodes_block(node);
diff --git a/ir/lower/lower_calls.c b/ir/lower/lower_calls.c
index 749050b..a90dd76 100644
--- a/ir/lower/lower_calls.c
+++ b/ir/lower/lower_calls.c
@@ -11,7 +11,6 @@
#include "lower_calls.h"
#include "array.h"
-#include "be.h"
#include "firm_types.h"
#include "heights.h"
#include "ircons.h"
diff --git a/ir/lower/lower_copyb.c b/ir/lower/lower_copyb.c
index efc5f68..81462ba 100644
--- a/ir/lower/lower_copyb.c
+++ b/ir/lower/lower_copyb.c
@@ -9,14 +9,15 @@
* @author Michael Beck, Matthias Braun, Manuel Mohr
*/
#include "adt/list.h"
-#include "be.h"
#include "ircons.h"
#include "irgmod.h"
#include "irgwalk.h"
#include "irnode_t.h"
+#include "iroptimize.h"
#include "irprog_t.h"
#include "lowering.h"
#include "panic.h"
+#include "target_t.h"
#include "type_t.h"
#include "util.h"
@@ -107,9 +108,8 @@ static ir_type *get_memcpy_methodtype(void)
static ir_node *get_memcpy_address(ir_graph *irg)
{
- ident *id = new_id_from_str("memcpy");
ir_type *mt = get_memcpy_methodtype();
- ir_entity *ent = create_compilerlib_entity(id, mt);
+ ir_entity *ent = create_compilerlib_entity("memcpy", mt);
return new_r_Address(irg, ent);
}
@@ -177,13 +177,11 @@ static void find_copyb_nodes(ir_node *irn, void *ctx)
void lower_CopyB(ir_graph *irg, unsigned max_small_sz, unsigned min_large_sz,
int allow_misaligns)
{
- const backend_params *bparams = be_get_backend_param();
-
assert(max_small_sz < min_large_sz && "CopyB size ranges must not overlap");
max_small_size = max_small_sz;
min_large_size = min_large_sz;
- native_mode_bytes = bparams->machine_size / 8;
+ native_mode_bytes = ir_target_pointer_size();
allow_misalignments = allow_misaligns;
walk_env_t env = { .copybs = NEW_ARR_F(ir_node*, 0) };
diff --git a/ir/lower/lower_dw.c b/ir/lower/lower_dw.c
index 835717b..9494956 100644
--- a/ir/lower/lower_dw.c
+++ b/ir/lower/lower_dw.c
@@ -12,7 +12,6 @@
#include "lower_dw.h"
#include "array.h"
-#include "be.h"
#include "constbits.h"
#include "dbginfo_t.h"
#include "debug.h"
@@ -36,6 +35,7 @@
#include "pdeq.h"
#include "pmap.h"
#include "set.h"
+#include "target_t.h"
#include "tv_t.h"
#include "type_t.h"
#include <assert.h>
@@ -143,7 +143,7 @@ static void lower_mode(void (*const set)(ir_type*, size_t, ir_type*), ir_type *c
} else if (!mode_is_signed(mode)) {
set(mtd, n++, tp_l_u);
set(mtd, n++, tp_u);
- } else if (be_is_big_endian()) {
+ } else if (ir_target_big_endian()) {
set(mtd, n++, tp_l_s);
set(mtd, n++, tp_u);
} else {
@@ -347,7 +347,7 @@ static void lower_Load(ir_node *node, ir_mode *mode)
ir_node *block = get_nodes_block(node);
ir_node *low;
ir_node *high;
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
low = new_r_Add(block, adr, cnst);
high = adr;
} else {
@@ -411,7 +411,7 @@ static void lower_Store(ir_node *node, ir_mode *mode)
ir_node *cnst = new_r_Const(irg, env.tv_mode_bytes);
ir_node *low;
ir_node *high;
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
low = new_r_Add(block, adr, cnst);
high = adr;
} else {
@@ -501,7 +501,7 @@ static void lower_Div(ir_node *node, ir_mode *mode)
opmode);
ir_node *in[4];
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
in[0] = get_lowered_high(left);
in[1] = get_lowered_low(left);
in[2] = get_lowered_high(right);
@@ -537,7 +537,7 @@ static void lower_Div(ir_node *node, ir_mode *mode)
set_Proj_num(proj, pn_Call_X_except);
break;
case pn_Div_res:
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
ir_node *res_low = new_r_Proj(resproj, env.p.word_unsigned, 1);
ir_node *res_high = new_r_Proj(resproj, mode, 0);
ir_set_dw_lowered(proj, res_low, res_high);
@@ -570,7 +570,7 @@ static void lower_Mod(ir_node *node, ir_mode *mode)
ir_node *addr = get_intrinsic_address(mtp, get_irn_op(node), opmode, opmode);
ir_node *in[4];
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
in[0] = get_lowered_high(left);
in[1] = get_lowered_low(left);
in[2] = get_lowered_high(right);
@@ -606,7 +606,7 @@ static void lower_Mod(ir_node *node, ir_mode *mode)
set_Proj_num(proj, pn_Call_X_except);
break;
case pn_Mod_res:
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
ir_node *res_low = new_r_Proj(resproj, env.p.word_unsigned, 1);
ir_node *res_high = new_r_Proj(resproj, mode, 0);
ir_set_dw_lowered(proj, res_low, res_high);
@@ -639,7 +639,7 @@ static void lower_binop(ir_node *node, ir_mode *mode)
ir_node *addr = get_intrinsic_address(mtp, get_irn_op(node), mode, mode);
ir_node *in[4];
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
in[0] = get_lowered_high(left);
in[1] = get_lowered_low(left);
in[2] = get_lowered_high(right);
@@ -655,7 +655,7 @@ static void lower_binop(ir_node *node, ir_mode *mode)
ir_node *resproj = new_r_Proj(call, mode_T, pn_Call_T_result);
set_irn_pinned(call, get_irn_pinned(node));
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
ir_node *res_low = new_r_Proj(resproj, env.p.word_unsigned, 1);
ir_node *res_high = new_r_Proj(resproj, mode, 0);
ir_set_dw_lowered(node, res_low, res_high);
@@ -959,7 +959,7 @@ static void lower_Minus(ir_node *node, ir_mode *mode)
ir_node *nomem = get_irg_no_mem(irg);
ir_node *in[2];
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
in[0] = get_lowered_high(op);
in[1] = get_lowered_low(op);
} else {
@@ -970,7 +970,7 @@ static void lower_Minus(ir_node *node, ir_mode *mode)
ir_node *resproj = new_r_Proj(call, mode_T, pn_Call_T_result);
set_irn_pinned(call, get_irn_pinned(node));
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
ir_node *res_low = new_r_Proj(resproj, env.p.word_unsigned, 1);
ir_node *res_high = new_r_Proj(resproj, mode, 0);
ir_set_dw_lowered(node, res_low, res_high);
@@ -1264,7 +1264,7 @@ static void lower_Conv_to_Ll(ir_node *node)
set_irn_pinned(call, get_irn_pinned(node));
irn = new_r_Proj(call, mode_T, pn_Call_T_result);
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
res_low = new_r_Proj(irn, low_unsigned, 1);
res_high = new_r_Proj(irn, low_signed, 0);
} else {
@@ -1292,7 +1292,7 @@ static void lower_Conv_from_Ll(ir_node *node)
set_Conv_op(node, entry->low_word);
} else {
ir_node *in[2];
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
in[0] = entry->high_word;
in[1] = entry->low_word;
} else {
@@ -1415,7 +1415,7 @@ transform:
ir_node *high = new_r_Add(block, addr, cnst);
ir_type *src_type = get_type_for_mode(src_mode);
/* big endian requires different order for lower/higher word */
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
ir_node *tmp = low;
low = high;
high = tmp;
@@ -1513,7 +1513,7 @@ static size_t lower_type(void (*const set)(ir_type*, size_t, ir_type*), ir_type
if (!mode_is_signed(mode)) {
set(mtp, n++, tp_l_u);
set(mtp, n++, tp_u);
- } else if (be_is_big_endian()) {
+ } else if (ir_target_big_endian()) {
set(mtp, n++, tp_l_s);
set(mtp, n++, tp_u);
} else {
@@ -1629,7 +1629,7 @@ static void lower_Return(ir_node *node, ir_mode *mode)
if (needs_lowering(pred_mode)) {
const lower64_entry_t *entry = get_node_entry(pred);
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
in[j++] = entry->high_word;
in[j++] = entry->low_word;
} else {
@@ -1702,7 +1702,7 @@ static void lower_Start(ir_node *node, ir_mode *high_mode)
ir_node *pred = get_Proj_pred(proj);
ir_node *res_low;
ir_node *res_high;
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
res_high = new_rd_Proj(dbg, pred, mode_h, new_projs[proj_nr]);
res_low = new_rd_Proj(dbg, pred, mode_l, new_projs[proj_nr] + 1);
} else {
@@ -1762,7 +1762,7 @@ static void lower_Call(ir_node *node, ir_mode *mode)
if (needs_lowering(pred_mode)) {
const lower64_entry_t *pred_entry = get_node_entry(pred);
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
in[j++] = pred_entry->high_word;
in[j++] = pred_entry->low_word;
} else {
@@ -1800,7 +1800,7 @@ static void lower_Call(ir_node *node, ir_mode *mode)
ir_node *pred = get_Proj_pred(proj);
ir_node *res_low;
ir_node *res_high;
- if (be_is_big_endian()) {
+ if (ir_target_big_endian()) {
res_high = new_rd_Proj(dbg, pred, mode_h, res_numbers[proj_nr]);
res_low = new_rd_Proj(dbg, pred, mode_l, res_numbers[proj_nr] + 1);
} else {
@@ -2083,7 +2083,7 @@ static ir_type *lower_Builtin_type(pmap *const type_map, ir_type *const mtp, ir_
*/
static ir_type *lower_Builtin_type_high(ir_type *mtp)
{
- ir_type *const tp_s_l = be_is_big_endian() ? tp_s : tp_u;
+ ir_type *const tp_s_l = ir_target_big_endian() ? tp_s : tp_u;
return lower_Builtin_type(lowered_builtin_type_high, mtp, tp_s_l, tp_u);
}
@@ -2094,7 +2094,7 @@ static ir_type *lower_Builtin_type_high(ir_type *mtp)
*/
static ir_type *lower_Builtin_type_low(ir_type *mtp)
{
- ir_type *const tp_s_l = !be_is_big_endian() ? tp_s : tp_u;
+ ir_type *const tp_s_l = !ir_target_big_endian() ? tp_s : tp_u;
return lower_Builtin_type(lowered_builtin_type_low, mtp, tp_s_l, tp_u);
}
@@ -2110,7 +2110,7 @@ static void lower_reduce_builtin(ir_node *builtin, ir_mode *mode)
if (!needs_lowering(operand_mode))
return;
- arch_allow_ifconv_func allow_ifconv = be_get_backend_param()->allow_ifconv;
+ arch_allow_ifconv_func allow_ifconv = ir_target.allow_ifconv;
const lower64_entry_t *entry = get_node_entry(operand);
dbg_info *dbgi = get_irn_dbg_info(builtin);
ir_graph *irg = get_irn_irg(builtin);
@@ -2576,8 +2576,8 @@ void ir_lower_dw_ops(void)
tp_l_s = new_type_primitive(env.p.word_signed);
tp_l_s->flags |= tf_lowered_dw;
- ir_type *const even = be_is_big_endian() ? tp_l_s : tp_l_u;
- ir_type *const odd = be_is_big_endian() ? tp_u : tp_s;
+ ir_type *const even = ir_target_big_endian() ? tp_l_s : tp_l_u;
+ ir_type *const odd = ir_target_big_endian() ? tp_u : tp_s;
binop_tp_u = make_type_4_2(tp_l_u, tp_u);
binop_tp_s = make_type_4_2(even, odd);
unop_tp_u = make_type_2_2(tp_l_u, tp_u);
diff --git a/ir/lower/lower_intrinsics.c b/ir/lower/lower_intrinsics.c
index 7d43b23..2f87ed8 100644
--- a/ir/lower/lower_intrinsics.c
+++ b/ir/lower/lower_intrinsics.c
@@ -9,7 +9,6 @@
* @author Michael Beck
*/
#include "array.h"
-#include "be.h"
#include "ircons_t.h"
#include "irgmod.h"
#include "irgopt.h"
@@ -23,6 +22,7 @@
#include "lowering.h"
#include "panic.h"
#include "pmap.h"
+#include "target_t.h"
#include "tv_t.h"
#include "util.h"
#include <stdbool.h>
@@ -174,7 +174,7 @@ int i_mapper_abs(ir_node *call)
ir_node *cmp = new_rd_Cmp(dbg, block, op, zero, ir_relation_less);
ir_node *minus_op = new_rd_Minus(dbg, block, op);
ir_node *mux;
- arch_allow_ifconv_func allow_ifconv = be_get_backend_param()->allow_ifconv;
+ arch_allow_ifconv_func allow_ifconv = ir_target.allow_ifconv;
/* mux allowed by backend? */
if (!allow_ifconv(cmp, op, minus_op))
@@ -271,7 +271,7 @@ int i_mapper_pow(ir_node *call)
ir_node *div;
ir_mode *mode = result_mode;
- ir_mode *float_arithmetic = be_get_backend_param()->mode_float_arithmetic;
+ ir_mode *float_arithmetic = ir_target.mode_float_arithmetic;
if (float_arithmetic != NULL) {
left = new_r_Conv(block, left, float_arithmetic);
mode = float_arithmetic;
diff --git a/ir/lower/lower_softfloat.c b/ir/lower/lower_softfloat.c
index 00c5cd5..31c3687 100644
--- a/ir/lower/lower_softfloat.c
+++ b/ir/lower/lower_softfloat.c
@@ -10,7 +10,6 @@
*/
#include "lower_softfloat.h"
-#include "be.h"
#include "dbginfo_t.h"
#include "ircons_t.h"
#include "iredges_t.h"
@@ -25,6 +24,7 @@
#include "lowering.h"
#include "panic.h"
#include "pmap.h"
+#include "target_t.h"
#include "tv_t.h"
#include "type_t.h"
#include <stdbool.h>
@@ -269,7 +269,7 @@ static ir_node *create_softfloat_address(const ir_node *n, const char *name)
new_id_fmt("__%s%s%s%s", name, first_param, second_param, result);
ir_graph *const irg = get_irn_irg(n);
- ir_entity *const ent = create_compilerlib_entity(id, method);
+ ir_entity *const ent = create_compilerlib_entity(get_id_str(id), method);
return new_r_Address(irg, ent);
}
@@ -507,8 +507,7 @@ static bool lower_Cmp(ir_node *const n)
ir_node *const mux = new_rd_Mux(dbgi, block, cmp, result, zero);
- arch_allow_ifconv_func const allow_ifconv
- = be_get_backend_param()->allow_ifconv;
+ arch_allow_ifconv_func const allow_ifconv = ir_target.allow_ifconv;
if (!allow_ifconv(cmp, result, zero))
ir_nodeset_insert(&created_mux_nodes, mux);