mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-11 03:45:33 +00:00
Branches: main Store double-precision `float' constructor arguments in unboxed form, in high-level C grades on 32-bit platforms, i.e. `float' (and equivalent) arguments may occupy two machine words. As the C code generated by the MLDS back-end makes use of MR_Float variables and parameters, float (un)boxing may be reduced substantially in many programs. compiler/prog_data.m: Add `double_word' as a new option for constructor argument widths, only used for float arguments as yet. compiler/make_hlds_passes.m: Set constructor arguments to have `double_word' width if required, and possible. compiler/type_util.m: Add helper predicate. compiler/builtin_ops.m: compiler/c_util.m: compiler/llds.m: Add two new binary operators used by the MLDS back-end. compiler/arg_pack.m: Handle `double_word' arguments. compiler/ml_code_util.m: Deciding whether or not a float constructor argument requires boxing now depends on the width of the field. compiler/ml_global_data.m: When a float constant appears as an initialiser of a generic array element, it is now always unboxed, irrespective of --unboxed-float. compiler/ml_type_gen.m: Take double-word arguments into account when generating structure fields. compiler/ml_unify_gen.m: Handle double-word float constructor arguments in (de)constructions. In some cases we break a float argument into its two words, so generating two assignments statements or two separate rvals. Take double-word arguments into account when calculating field offsets. compiler/mlds_to_c.m: The new binary operators require no changes here. As a special case, write `MR_float_from_dword_ptr(&X)' instead of `MR_float_from_dword(X, Y)' when X, Y are consecutive words within a field. The definition of `MR_float_from_dword_ptr' is more straightforward, and gcc produces better code than if we use the more general `MR_float_from_dword'. compiler/rtti_out.m: For double-word arguments, generate MR_DuArgLocn structures with MR_arg_bits set to -1. compiler/rtti_to_mlds.m: Handle double-word arguments in field offset calculation. compiler/unify_gen.m: Partially handle double_word arguments in LLDS back-end. compiler/handle_options.m: Set --unboxed-float when targetting Java, C# and Erlang. compiler/structure_reuse.direct.choose_reuse.m: Rename a predicate. compiler/bytecode.m: compiler/equiv_type.m: compiler/equiv_type_hlds.m: compiler/llds_to_x86_64.m: compiler/mlds_to_gcc.m: compiler/mlds_to_il.m: compiler/opt_debug.m: Conform to changes. library/construct.m: library/store.m: Handle double-word constructor arguments. runtime/mercury_conf.h.in: Clarify what `MR_BOXED_FLOAT' now means. runtime/mercury_float.h: Add helper macros for converting between doubles and word/dwords. runtime/mercury_deconstruct.c: runtime/mercury_deconstruct.h: Add a macro `MR_arg_value' and a helper function to extract a constructor argument value. This replaces `MR_unpack_arg'. runtime/mercury_type_info.h: Remove `MR_unpack_arg'. Document that MR_DuArgLocn.MR_arg_bits may be -1. runtime/mercury_deconstruct_macros.h: runtime/mercury_deep_copy_body.h: runtime/mercury_ml_arg_body.h: runtime/mercury_table_type_body.h: runtime/mercury_tabling.c: runtime/mercury_type_info.c: Handle double-word constructor arguments. tests/hard_coded/Mercury.options: tests/hard_coded/Mmakefile: tests/hard_coded/lco_double.exp: tests/hard_coded/lco_double.m: tests/hard_coded/pack_args_float.exp: tests/hard_coded/pack_args_float.m: Add test cases. trace/mercury_trace_vars.c: Conform to changes.
96 lines
4.5 KiB
C
96 lines
4.5 KiB
C
/*
|
|
** vim:ts=4 sw=4 expandtab
|
|
*/
|
|
/*
|
|
** Copyright (C) 2002-2004, 2007, 2011 The University of Melbourne.
|
|
** This file may only be copied under the terms of the GNU Library General
|
|
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
*/
|
|
|
|
/*
|
|
** mercury_deconstruct_macros.h
|
|
**
|
|
** This file defines macros for performing tasks that are useful when
|
|
** deconstructing terms,
|
|
*/
|
|
|
|
#ifndef MERCURY_DECONSTRUCT_MACROS_H
|
|
#define MERCURY_DECONSTRUCT_MACROS_H
|
|
|
|
/*
|
|
** Check for attempts to deconstruct a non-canonical type.
|
|
** Such deconstructions must be cc_multi, which is why we treat
|
|
** violations of this as runtime errors in det deconstruction
|
|
** predicates.
|
|
** (There ought to be cc_multi versions of those predicates.)
|
|
*/
|
|
#define MR_abort_if_type_is_noncanonical(ei, msg) \
|
|
do { \
|
|
if ((ei).non_canonical_type) { \
|
|
MR_fatal_error(msg); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define MR_noncanon_msg(predname) \
|
|
"called " predname " for non-canonical type"
|
|
|
|
#define MR_deconstruct_get_functor(ei, functor_field, var) \
|
|
do { \
|
|
MR_make_aligned_string(var, (ei).functor_field); \
|
|
} while (0)
|
|
|
|
#define MR_deconstruct_get_functor_number(ei, var) \
|
|
do { \
|
|
var = (ei).functor_number; \
|
|
} while (0)
|
|
|
|
#define MR_deconstruct_get_arity(ei, var) \
|
|
do { \
|
|
var = (ei).arity; \
|
|
} while (0)
|
|
|
|
#define MR_deconstruct_get_arg_list(ei, args_field, var) \
|
|
do { \
|
|
int i; \
|
|
\
|
|
var = MR_list_empty_msg(MR_ALLOC_ID); \
|
|
i = (ei).arity; \
|
|
\
|
|
while (--i >= 0) { \
|
|
MR_Word arg; \
|
|
MR_Word val; \
|
|
\
|
|
if ((ei).args_field.arg_locns == NULL) { \
|
|
val = (ei).args_field.arg_values[i + \
|
|
(ei).args_field.num_extra_args]; \
|
|
} else { \
|
|
const MR_DuArgLocn *locn = \
|
|
&(ei).args_field.arg_locns[i]; \
|
|
MR_Word *argp = &(ei).args_field.arg_values[ \
|
|
locn->MR_arg_offset + \
|
|
(ei).args_field.num_extra_args]; \
|
|
val = MR_arg_value(argp, locn); \
|
|
} \
|
|
\
|
|
/* Create an argument on the heap */ \
|
|
MR_new_univ_on_hp(arg, \
|
|
(ei).args_field.arg_type_infos[i], val); \
|
|
\
|
|
/* Join the argument to the front of the list */ \
|
|
var = MR_univ_list_cons_msg(arg, var, MR_ALLOC_ID); \
|
|
} \
|
|
} while (0)
|
|
|
|
/*
|
|
** Free any arg_type_infos allocated by the MR_expand variant.
|
|
** Should be called after we have used them for the last time.
|
|
*/
|
|
#define MR_deconstruct_free_allocated_arg_type_infos(ei, args_field)\
|
|
do { \
|
|
if ((ei).args_field.can_free_arg_type_infos) { \
|
|
MR_GC_free((ei).args_field.arg_type_infos); \
|
|
} \
|
|
} while (0)
|
|
|
|
#endif /* MERCURY_DECONSTRUCT_MACROS_H */
|