summaryrefslogtreecommitdiffhomepage
path: root/ir/be/TEMPLATE
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/be/TEMPLATE
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/be/TEMPLATE')
-rw-r--r--ir/be/TEMPLATE/TEMPLATE_bearch.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/ir/be/TEMPLATE/TEMPLATE_bearch.c b/ir/be/TEMPLATE/TEMPLATE_bearch.c
index 6167e23..8d9067f 100644
--- a/ir/be/TEMPLATE/TEMPLATE_bearch.c
+++ b/ir/be/TEMPLATE/TEMPLATE_bearch.c
@@ -21,9 +21,11 @@
#include "gen_TEMPLATE_regalloc_if.h"
#include "iredges_t.h"
#include "irprog_t.h"
+#include "isas.h"
#include "lower_builtins.h"
#include "lower_calls.h"
#include "panic.h"
+#include "target_t.h"
/**
* Transforms the standard firm graph into a TEMPLATE firm graph
@@ -106,10 +108,12 @@ static void TEMPLATE_generate_code(FILE *output, const char *cup_name)
static void TEMPLATE_init(void)
{
- ir_mode *const ptr_mode = new_reference_mode("p32", 32, 32);
- set_modeP(ptr_mode);
TEMPLATE_register_init();
TEMPLATE_create_opcodes();
+
+ ir_target.experimental
+ = "The TEMPLATE backend is just a demo for writing backends";
+ ir_target.float_int_overflow = ir_overflow_min_max;
}
static void TEMPLATE_finish(void)
@@ -127,35 +131,6 @@ static void TEMPLATE_lower_for_target(void)
be_after_irp_transform("lower-calls");
}
-static int TEMPLATE_is_mux_allowed(ir_node *sel, ir_node *mux_false,
- ir_node *mux_true)
-{
- (void)sel;
- (void)mux_false;
- (void)mux_true;
- return false;
-}
-
-/**
- * Returns the libFirm configuration parameter for this backend.
- */
-static const backend_params *TEMPLATE_get_backend_params(void)
-{
- static backend_params p = {
- .experimental = "The TEMPLATE backend is just a demo for writing backends",
- .byte_order_big_endian = false,
- .pic_supported = false,
- .unaligned_memaccess_supported = false,
- .modulo_shift = 32,
- .allow_ifconv = TEMPLATE_is_mux_allowed,
- .machine_size = 32,
- .mode_float_arithmetic = NULL,
- .type_long_double = NULL,
- .float_int_overflow = ir_overflow_min_max,
- };
- return &p;
-}
-
static unsigned TEMPLATE_get_op_estimated_cost(const ir_node *node)
{
if (is_TEMPLATE_Load(node))
@@ -165,14 +140,19 @@ static unsigned TEMPLATE_get_op_estimated_cost(const ir_node *node)
return 1;
}
-static arch_isa_if_t const TEMPLATE_isa_if = {
+arch_isa_if_t const TEMPLATE_isa_if = {
+ .name = "TEMPLATE",
+ .pointer_size = 4,
+ .modulo_shift = 32,
+ .big_endian = false,
+ .po2_biggest_alignment = 3,
+ .pic_supported = false,
.n_registers = N_TEMPLATE_REGISTERS,
.registers = TEMPLATE_registers,
.n_register_classes = N_TEMPLATE_CLASSES,
.register_classes = TEMPLATE_reg_classes,
.init = TEMPLATE_init,
.finish = TEMPLATE_finish,
- .get_params = TEMPLATE_get_backend_params,
.generate_code = TEMPLATE_generate_code,
.lower_for_target = TEMPLATE_lower_for_target,
.is_valid_clobber = be_default_is_valid_clobber,
@@ -182,6 +162,5 @@ static arch_isa_if_t const TEMPLATE_isa_if = {
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_TEMPLATE)
void be_init_arch_TEMPLATE(void)
{
- be_register_isa_if("TEMPLATE", &TEMPLATE_isa_if);
TEMPLATE_init_transform();
}