2002-10-22 14:53:18 +00:00
|
|
|
/*
|
2011-03-22 03:24:39 +00:00
|
|
|
value.c
|
2001-04-01 06:01:02 +00:00
|
|
|
|
2011-03-22 03:24:39 +00:00
|
|
|
value handling
|
2001-04-01 06:01:02 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Copyright (C) 2002 Bill Currie <bill@taniwha.org>
|
2001-04-01 06:01:02 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2002/06/04
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
2001-04-01 06:01:02 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2002-06-01 04:41:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2012-12-06 11:52:53 +00:00
|
|
|
#include "QF/alloc.h"
|
2002-06-02 01:10:31 +00:00
|
|
|
#include "QF/dstring.h"
|
2001-04-01 06:01:02 +00:00
|
|
|
#include "QF/hash.h"
|
2002-10-20 03:31:49 +00:00
|
|
|
#include "QF/mathlib.h"
|
2022-11-16 08:55:56 +00:00
|
|
|
#include "QF/progs.h"
|
2002-06-01 05:06:19 +00:00
|
|
|
#include "QF/va.h"
|
2001-04-01 06:01:02 +00:00
|
|
|
|
2022-04-29 02:22:40 +00:00
|
|
|
#include "QF/simd/types.h"
|
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "tools/qfcc/include/qfcc.h"
|
|
|
|
#include "tools/qfcc/include/def.h"
|
|
|
|
#include "tools/qfcc/include/defspace.h"
|
|
|
|
#include "tools/qfcc/include/diagnostic.h"
|
|
|
|
#include "tools/qfcc/include/emit.h"
|
|
|
|
#include "tools/qfcc/include/expr.h"
|
2022-11-16 08:55:56 +00:00
|
|
|
#include "tools/qfcc/include/options.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "tools/qfcc/include/reloc.h"
|
|
|
|
#include "tools/qfcc/include/strpool.h"
|
|
|
|
#include "tools/qfcc/include/symtab.h"
|
|
|
|
#include "tools/qfcc/include/type.h"
|
|
|
|
#include "tools/qfcc/include/value.h"
|
2001-04-01 06:01:02 +00:00
|
|
|
|
2022-07-31 08:34:09 +00:00
|
|
|
//FIXME I don't like this being here (or aligned_alloc being necessary in
|
|
|
|
//the first place, but not at all sure what to do about that)
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define aligned_alloc(al, sz) _aligned_malloc(sz, al)
|
2022-09-19 12:37:08 +00:00
|
|
|
#define free(x) _aligned_free(x)
|
2022-07-31 08:34:09 +00:00
|
|
|
#endif
|
|
|
|
|
2002-10-20 03:31:49 +00:00
|
|
|
typedef struct {
|
|
|
|
def_t *def;
|
|
|
|
union {
|
2022-04-29 02:27:27 +00:00
|
|
|
#define EV_TYPE(type) pr_##type##_t type##_val;
|
|
|
|
#include "QF/progs/pr_type_names.h"
|
|
|
|
#define VEC_TYPE(type_name, base_type) pr_##type_name##_t type_name##_val;
|
|
|
|
#include "tools/qfcc/include/vec_types.h"
|
2002-10-20 03:31:49 +00:00
|
|
|
ex_pointer_t pointer;
|
|
|
|
} i;
|
|
|
|
} immediate_t;
|
|
|
|
|
2012-07-18 14:01:09 +00:00
|
|
|
static hashtab_t *value_table;
|
2013-03-08 13:16:31 +00:00
|
|
|
static ex_value_t *values_freelist;
|
2012-07-18 14:01:09 +00:00
|
|
|
|
2022-11-16 08:55:56 +00:00
|
|
|
//FIXME this (to setup_value_progs) should be in its own file and more
|
|
|
|
//general (good for constant folding, too, and maybe some others).
|
|
|
|
static void
|
|
|
|
value_debug_handler (prdebug_t event, void *param, void *data)
|
|
|
|
{
|
|
|
|
progs_t *pr = data;
|
|
|
|
switch (event) {
|
|
|
|
case prd_trace:
|
|
|
|
dstatement_t *st = pr->pr_statements + pr->pr_xstatement;
|
|
|
|
PR_PrintStatement (pr, st, 0);
|
|
|
|
break;
|
|
|
|
case prd_breakpoint:
|
|
|
|
case prd_subenter:
|
|
|
|
case prd_subexit:
|
|
|
|
case prd_runerror:
|
|
|
|
case prd_watchpoint:
|
|
|
|
case prd_begin:
|
|
|
|
case prd_terminate:
|
|
|
|
case prd_error:
|
|
|
|
case prd_none:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
|
|
|
vf_null,
|
|
|
|
vf_convert,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BASE(b, base) (((base) & 3) << OP_##b##_SHIFT)
|
|
|
|
#define OP(a, b, c, op) ((op) | BASE(A, a) | BASE(B, b) | BASE(C, c))
|
|
|
|
|
|
|
|
static bfunction_t value_functions[] = {
|
|
|
|
{}, // null function
|
|
|
|
[vf_convert] = { .first_statement = vf_convert * 16 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static __attribute__((aligned(64)))
|
|
|
|
dstatement_t value_statements[] = {
|
|
|
|
[vf_convert * 16 - 1] = {},
|
|
|
|
{ OP_CONV, 0, 07777, 16 },
|
|
|
|
{ OP_RETURN, 16, 0, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
#define num_globals 16384
|
|
|
|
#define stack_size 8192
|
|
|
|
static __attribute__((aligned(64)))
|
|
|
|
pr_type_t value_globals[num_globals + 128] = {
|
|
|
|
[num_globals - stack_size] = { .uint_value = num_globals },
|
|
|
|
};
|
|
|
|
|
|
|
|
static dprograms_t value_progs = {
|
|
|
|
.version = PROG_VERSION,
|
|
|
|
.statements = {
|
|
|
|
.count = sizeof (value_statements) / sizeof (value_statements[0]),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
static progs_t value_pr = {
|
|
|
|
.progs = &value_progs,
|
|
|
|
.debug_handler = value_debug_handler,
|
|
|
|
.debug_data = &value_pr,
|
|
|
|
.pr_trace = 1,
|
|
|
|
.pr_trace_depth = -1,
|
|
|
|
.function_table = value_functions,
|
|
|
|
.pr_statements = value_statements,
|
|
|
|
.globals_size = num_globals,
|
|
|
|
.pr_globals = value_globals,
|
|
|
|
.stack_bottom = num_globals - stack_size + 4,
|
|
|
|
.pr_return_buffer = value_globals + num_globals,
|
|
|
|
.pr_return = value_globals + num_globals,
|
|
|
|
.globals = {
|
|
|
|
.stack = (pr_ptr_t *) (value_globals + num_globals - stack_size),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_value_progs (void)
|
|
|
|
{
|
|
|
|
PR_Init (&value_pr);
|
|
|
|
PR_Debug_Init (&value_pr);
|
|
|
|
}
|
|
|
|
|
2012-07-18 14:01:09 +00:00
|
|
|
static uintptr_t
|
|
|
|
value_get_hash (const void *_val, void *unused)
|
|
|
|
{
|
|
|
|
const ex_value_t *val = (const ex_value_t *) _val;
|
2020-03-06 11:33:47 +00:00
|
|
|
return Hash_Buffer (&val->v, sizeof (val->v)) ^ (uintptr_t) val->type;
|
2012-07-18 14:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
value_compare (const void *_val1, const void *_val2, void *unused)
|
|
|
|
{
|
|
|
|
const ex_value_t *val1 = (const ex_value_t *) _val1;
|
|
|
|
const ex_value_t *val2 = (const ex_value_t *) _val2;
|
2020-03-06 11:33:47 +00:00
|
|
|
if (val1->type != val2->type)
|
2012-07-18 14:01:09 +00:00
|
|
|
return 0;
|
|
|
|
return memcmp (&val1->v, &val2->v, sizeof (val1->v)) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ex_value_t *
|
|
|
|
new_value (void)
|
|
|
|
{
|
|
|
|
ex_value_t *value;
|
2022-07-26 12:36:56 +00:00
|
|
|
#define malloc(x) aligned_alloc (__alignof__(ex_value_t), x)
|
2012-07-18 14:01:09 +00:00
|
|
|
ALLOC (256, ex_value_t, values, value);
|
2022-07-26 12:36:56 +00:00
|
|
|
#undef malloc
|
2012-07-18 14:01:09 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2018-10-12 13:05:17 +00:00
|
|
|
static void
|
|
|
|
set_val_type (ex_value_t *val, type_t *type)
|
|
|
|
{
|
|
|
|
val->type = type;
|
|
|
|
val->lltype = low_level_type (type);
|
|
|
|
}
|
|
|
|
|
2012-07-18 14:01:09 +00:00
|
|
|
static ex_value_t *
|
|
|
|
find_value (const ex_value_t *val)
|
|
|
|
{
|
|
|
|
ex_value_t *value;
|
|
|
|
|
|
|
|
value = Hash_FindElement (value_table, val);
|
|
|
|
if (value)
|
|
|
|
return value;
|
|
|
|
value = new_value ();
|
|
|
|
*value = *val;
|
2012-11-20 04:33:57 +00:00
|
|
|
Hash_AddElement (value_table, value);
|
2012-07-18 14:01:09 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
|
|
|
new_string_val (const char *string_val)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, &type_string);
|
2012-07-18 14:01:09 +00:00
|
|
|
if (string_val)
|
|
|
|
val.v.string_val = save_string (string_val);
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
2020-02-14 07:38:37 +00:00
|
|
|
ex_value_t *
|
|
|
|
new_double_val (double double_val)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
|
|
|
memset (&val, 0, sizeof (val));
|
|
|
|
set_val_type (&val, &type_double);
|
|
|
|
val.v.double_val = double_val;
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
2012-07-18 14:01:09 +00:00
|
|
|
ex_value_t *
|
|
|
|
new_float_val (float float_val)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, &type_float);
|
2012-07-18 14:01:09 +00:00
|
|
|
val.v.float_val = float_val;
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
|
|
|
new_vector_val (const float *vector_val)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, &type_vector);
|
2012-07-18 14:01:09 +00:00
|
|
|
VectorCopy (vector_val, val.v.vector_val);
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
|
|
|
new_entity_val (int entity_val)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, &type_entity);
|
2012-07-18 14:01:09 +00:00
|
|
|
val.v.entity_val = entity_val;
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
|
|
|
new_field_val (int field_val, type_t *type, def_t *def)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, field_type (type));
|
2012-07-18 14:01:09 +00:00
|
|
|
val.v.pointer.val = field_val;
|
|
|
|
val.v.pointer.type = type;
|
|
|
|
val.v.pointer.def = def;
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
2012-11-21 01:06:15 +00:00
|
|
|
new_func_val (int func_val, type_t *type)
|
2012-07-18 14:01:09 +00:00
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, type);
|
2012-11-21 01:06:15 +00:00
|
|
|
val.v.func_val.val = func_val;
|
|
|
|
val.v.func_val.type = type;
|
2012-07-18 14:01:09 +00:00
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
2020-03-16 03:15:55 +00:00
|
|
|
new_pointer_val (int pointer_val, type_t *type, def_t *def,
|
2020-03-17 06:28:15 +00:00
|
|
|
struct operand_s *tempop)
|
2012-07-18 14:01:09 +00:00
|
|
|
{
|
|
|
|
ex_value_t val;
|
2019-06-10 14:52:39 +00:00
|
|
|
if (!type) {
|
|
|
|
internal_error (0, "pointer value with no type");
|
|
|
|
}
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, pointer_type (type));
|
2012-07-18 14:01:09 +00:00
|
|
|
val.v.pointer.val = pointer_val;
|
|
|
|
val.v.pointer.type = type;
|
|
|
|
val.v.pointer.def = def;
|
2020-03-16 03:15:55 +00:00
|
|
|
val.v.pointer.tempop = tempop;
|
2012-07-18 14:01:09 +00:00
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
|
|
|
new_quaternion_val (const float *quaternion_val)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, &type_quaternion);
|
2012-07-18 14:01:09 +00:00
|
|
|
QuatCopy (quaternion_val, val.v.quaternion_val);
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
2022-01-18 04:21:06 +00:00
|
|
|
new_int_val (int int_val)
|
2012-07-18 14:01:09 +00:00
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2022-01-18 04:21:06 +00:00
|
|
|
set_val_type (&val, &type_int);
|
|
|
|
val.v.int_val = int_val;
|
2012-07-18 14:01:09 +00:00
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
2022-01-18 04:21:06 +00:00
|
|
|
new_uint_val (int uint_val)
|
2012-07-18 14:01:09 +00:00
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2022-01-18 04:21:06 +00:00
|
|
|
set_val_type (&val, &type_uint);
|
|
|
|
val.v.uint_val = uint_val;
|
2012-07-18 14:01:09 +00:00
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
2022-04-29 06:38:55 +00:00
|
|
|
ex_value_t *
|
|
|
|
new_long_val (pr_long_t long_val)
|
|
|
|
{
|
|
|
|
ex_value_t val = { .v = { .long_val = long_val } };
|
|
|
|
set_val_type (&val, &type_long);
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
|
|
|
new_ulong_val (pr_ulong_t ulong_val)
|
|
|
|
{
|
|
|
|
ex_value_t val = { .v = { .ulong_val = ulong_val } };
|
|
|
|
set_val_type (&val, &type_ulong);
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
2012-07-18 14:01:09 +00:00
|
|
|
ex_value_t *
|
|
|
|
new_short_val (short short_val)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, &type_short);
|
2012-07-18 14:01:09 +00:00
|
|
|
val.v.short_val = short_val;
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex_value_t *
|
|
|
|
new_nil_val (type_t *type)
|
|
|
|
{
|
|
|
|
ex_value_t val;
|
2012-07-19 01:10:30 +00:00
|
|
|
memset (&val, 0, sizeof (val));
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&val, type);
|
|
|
|
if (val.lltype == ev_void) {
|
|
|
|
val.lltype = type_nil->type;
|
|
|
|
}
|
2022-01-18 05:36:06 +00:00
|
|
|
if (val.lltype == ev_ptr || val.lltype == ev_field )
|
2012-07-18 14:01:09 +00:00
|
|
|
val.v.pointer.type = type->t.fldptr.type;
|
2018-10-12 13:05:17 +00:00
|
|
|
if (val.lltype == ev_func)
|
2012-11-21 01:06:15 +00:00
|
|
|
val.v.func_val.type = type;
|
2012-07-18 14:01:09 +00:00
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
2022-04-27 12:24:46 +00:00
|
|
|
ex_value_t *
|
|
|
|
new_type_value (const type_t *type, const pr_type_t *data)
|
|
|
|
{
|
|
|
|
size_t typeSize = type_size (type) * sizeof (pr_type_t);
|
|
|
|
ex_value_t val = {};
|
|
|
|
set_val_type (&val, (type_t *) type);//FIXME cast
|
|
|
|
memcpy (&val.v, data, typeSize);
|
|
|
|
return find_value (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
value_store (pr_type_t *dst, const type_t *dstType, const expr_t *src)
|
|
|
|
{
|
|
|
|
size_t dstSize = type_size (dstType) * sizeof (pr_type_t);
|
|
|
|
|
|
|
|
if (src->type == ex_nil) {
|
|
|
|
memset (dst, 0, dstSize);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (src->type == ex_symbol && src->e.symbol->sy_type == sy_var) {
|
|
|
|
// initialized global def treated as a constant
|
|
|
|
// from the tests in cast_expr, the def is known to be constant
|
|
|
|
def_t *def = src->e.symbol->s.def;
|
|
|
|
memcpy (dst, &D_PACKED (pr_type_t, def), dstSize);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ex_value_t *val = 0;
|
|
|
|
if (src->type == ex_value) {
|
|
|
|
val = src->e.value;
|
|
|
|
}
|
|
|
|
if (src->type == ex_symbol && src->e.symbol->sy_type == sy_const) {
|
|
|
|
val = src->e.symbol->s.value;
|
|
|
|
}
|
|
|
|
if (!val) {
|
|
|
|
internal_error (src, "unexpected constant expression type");
|
|
|
|
}
|
|
|
|
memcpy (dst, &val->v, dstSize);
|
|
|
|
}
|
|
|
|
|
2022-04-29 02:22:40 +00:00
|
|
|
const char *
|
|
|
|
get_value_string (const ex_value_t *value)
|
|
|
|
{
|
|
|
|
const type_t *type = value->type;
|
|
|
|
const char *str = "";
|
|
|
|
switch (type->type) {
|
|
|
|
case ev_string:
|
|
|
|
return va (0, "\"%s\"", quote_string (value->v.string_val));
|
|
|
|
case ev_vector:
|
|
|
|
case ev_quaternion:
|
|
|
|
case ev_float:
|
|
|
|
switch (type_width (type)) {
|
|
|
|
case 1:
|
|
|
|
str = va (0, "%.9g", value->v.float_val);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
str = va (0, VEC2F_FMT, VEC2_EXP (value->v.vec2_val));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
str = va (0, "[%.9g, %.9g, %.9g]",
|
|
|
|
VectorExpand (value->v.vec3_val));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
str = va (0, VEC4F_FMT, VEC4_EXP (value->v.vec4_val));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return va (0, "%s %s", type->name, str);
|
|
|
|
case ev_entity:
|
|
|
|
case ev_func:
|
|
|
|
return va (0, "%s %d", type->name, value->v.int_val);
|
|
|
|
case ev_field:
|
|
|
|
if (value->v.pointer.def) {
|
|
|
|
int offset = value->v.pointer.val;
|
|
|
|
offset += value->v.pointer.def->offset;
|
|
|
|
return va (0, "field %d", offset);
|
|
|
|
} else {
|
|
|
|
return va (0, "field %d", value->v.pointer.val);
|
|
|
|
}
|
|
|
|
case ev_ptr:
|
|
|
|
if (value->v.pointer.def) {
|
|
|
|
str = va (0, "<%s>", value->v.pointer.def->name);
|
|
|
|
}
|
|
|
|
return va (0, "(* %s)[%d]%s",
|
|
|
|
value->v.pointer.type
|
|
|
|
? get_type_string (value->v.pointer.type) : "???",
|
|
|
|
value->v.pointer.val, str);
|
|
|
|
case ev_int:
|
|
|
|
switch (type_width (type)) {
|
|
|
|
case 1:
|
|
|
|
str = va (0, "%"PRIi32, value->v.int_val);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
str = va (0, VEC2I_FMT, VEC2_EXP (value->v.ivec2_val));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
str = va (0, "[%"PRIi32", %"PRIi32", %"PRIi32"]",
|
|
|
|
VectorExpand (value->v.ivec3_val));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
str = va (0, VEC4I_FMT, VEC4_EXP (value->v.ivec4_val));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return va (0, "%s %s", type->name, str);
|
|
|
|
case ev_uint:
|
|
|
|
switch (type_width (type)) {
|
|
|
|
case 1:
|
|
|
|
str = va (0, "%"PRIu32, value->v.uint_val);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
str = va (0, "[%"PRIu32", %"PRIi32"]",
|
|
|
|
VEC2_EXP (value->v.uivec2_val));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
str = va (0, "[%"PRIu32", %"PRIi32", %"PRIi32"]",
|
|
|
|
VectorExpand (value->v.uivec3_val));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
str = va (0, "[%"PRIu32", %"PRIi32", %"PRIi32", %"PRIi32"]",
|
|
|
|
VEC4_EXP (value->v.uivec4_val));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return va (0, "%s %s", type->name, str);
|
|
|
|
case ev_short:
|
|
|
|
return va (0, "%s %"PRIi16, type->name, value->v.short_val);
|
|
|
|
case ev_ushort:
|
|
|
|
return va (0, "%s %"PRIu16, type->name, value->v.ushort_val);
|
|
|
|
case ev_double:
|
|
|
|
switch (type_width (type)) {
|
|
|
|
case 1:
|
|
|
|
str = va (0, "%.17g", value->v.double_val);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
str = va (0, VEC2D_FMT, VEC2_EXP (value->v.dvec2_val));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
str = va (0, "[%.17g, %.17g, %.17g]",
|
|
|
|
VectorExpand (value->v.dvec3_val));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
str = va (0, VEC4D_FMT, VEC4_EXP (value->v.dvec4_val));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return va (0, "%s %s", type->name, str);
|
|
|
|
case ev_long:
|
|
|
|
switch (type_width (type)) {
|
|
|
|
case 1:
|
|
|
|
str = va (0, "%"PRIi64, value->v.long_val);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
str = va (0, VEC2L_FMT, VEC2_EXP (value->v.lvec2_val));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
str = va (0, "[%"PRIi64", %"PRIi64", %"PRIi64"]",
|
|
|
|
VectorExpand (value->v.lvec3_val));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
str = va (0, VEC4L_FMT, VEC4_EXP (value->v.lvec4_val));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return va (0, "%s %s", type->name, str);
|
|
|
|
case ev_ulong:
|
|
|
|
switch (type_width (type)) {
|
|
|
|
case 1:
|
|
|
|
str = va (0, "%"PRIu64, value->v.ulong_val);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
str = va (0, "[%"PRIu64", %"PRIi64"]",
|
|
|
|
VEC2_EXP (value->v.ulvec2_val));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
str = va (0, "[%"PRIu64", %"PRIi64", %"PRIi64"]",
|
|
|
|
VectorExpand (value->v.ulvec3_val));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
str = va (0, "[%"PRIu64", %"PRIi64", %"PRIi64", %"PRIi64"]",
|
|
|
|
VEC4_EXP (value->v.ulvec4_val));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return va (0, "%s %s", type->name, str);
|
|
|
|
case ev_void:
|
|
|
|
return "<void>";
|
|
|
|
case ev_invalid:
|
|
|
|
return "<invalid>";
|
|
|
|
case ev_type_count:
|
|
|
|
return "<type_count>";
|
|
|
|
}
|
|
|
|
return "invalid type";
|
|
|
|
}
|
|
|
|
|
2001-12-06 19:49:40 +00:00
|
|
|
static hashtab_t *string_imm_defs;
|
2022-04-29 02:27:27 +00:00
|
|
|
static hashtab_t *fldptr_imm_defs;
|
|
|
|
static hashtab_t *value_imm_defs;
|
2001-04-01 06:01:02 +00:00
|
|
|
|
2012-12-01 11:53:58 +00:00
|
|
|
static void
|
|
|
|
imm_free (void *_imm, void *unused)
|
|
|
|
{
|
|
|
|
free (_imm);
|
|
|
|
}
|
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
static __attribute__((pure)) uintptr_t
|
2012-07-18 13:34:37 +00:00
|
|
|
imm_get_hash (const void *_imm, void *_tab)
|
2001-04-01 06:01:02 +00:00
|
|
|
{
|
2002-10-20 03:31:49 +00:00
|
|
|
immediate_t *imm = (immediate_t *) _imm;
|
|
|
|
hashtab_t **tab = (hashtab_t **) _tab;
|
2001-12-06 19:49:40 +00:00
|
|
|
|
2002-10-20 03:31:49 +00:00
|
|
|
if (tab == &string_imm_defs) {
|
2003-03-03 21:09:41 +00:00
|
|
|
const char *str = pr.strings->strings + imm->i.string_val;
|
|
|
|
return str ? Hash_String (str) : 0;
|
2022-04-29 02:27:27 +00:00
|
|
|
} else if (tab == &fldptr_imm_defs) {
|
2011-03-21 09:10:58 +00:00
|
|
|
return Hash_Buffer (&imm->i.pointer, sizeof (&imm->i.pointer));
|
2022-04-29 02:27:27 +00:00
|
|
|
} else if (tab == &value_imm_defs) {
|
|
|
|
size_t size = type_size (imm->def->type) * sizeof (pr_type_t);
|
|
|
|
return Hash_Buffer (&imm->i, size) ^ (uintptr_t) imm->def->type;
|
2002-10-20 03:31:49 +00:00
|
|
|
} else {
|
2022-04-29 02:27:27 +00:00
|
|
|
internal_error (0, "invalid immediate hash table");
|
2002-10-20 03:31:49 +00:00
|
|
|
}
|
2001-06-26 07:21:20 +00:00
|
|
|
}
|
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
static __attribute__((pure)) int
|
2012-07-18 13:34:37 +00:00
|
|
|
imm_compare (const void *_imm1, const void *_imm2, void *_tab)
|
2001-07-18 06:37:14 +00:00
|
|
|
{
|
2002-10-20 03:31:49 +00:00
|
|
|
immediate_t *imm1 = (immediate_t *) _imm1;
|
|
|
|
immediate_t *imm2 = (immediate_t *) _imm2;
|
|
|
|
hashtab_t **tab = (hashtab_t **) _tab;
|
2001-12-06 19:49:40 +00:00
|
|
|
|
2002-10-20 03:31:49 +00:00
|
|
|
if (tab == &string_imm_defs) {
|
2003-03-03 21:09:41 +00:00
|
|
|
const char *str1 = pr.strings->strings + imm1->i.string_val;
|
|
|
|
const char *str2 = pr.strings->strings + imm2->i.string_val;
|
|
|
|
return (str1 == str2 || (str1 && str2 && !strcmp (str1, str2)));
|
2022-04-29 02:27:27 +00:00
|
|
|
} else if (tab == &fldptr_imm_defs) {
|
2002-10-20 03:31:49 +00:00
|
|
|
return !memcmp (&imm1->i.pointer, &imm2->i.pointer,
|
|
|
|
sizeof (imm1->i.pointer));
|
2022-04-29 02:27:27 +00:00
|
|
|
} else if (tab == &value_imm_defs) {
|
|
|
|
size_t size = type_size (imm1->def->type) * sizeof (pr_type_t);
|
|
|
|
return !memcmp (&imm1->i, &imm2->i, size);
|
2002-10-20 03:31:49 +00:00
|
|
|
} else {
|
2022-04-29 02:27:27 +00:00
|
|
|
internal_error (0, "invalid immediate hash table");
|
2002-10-20 03:31:49 +00:00
|
|
|
}
|
2001-07-18 06:37:14 +00:00
|
|
|
}
|
|
|
|
|
2002-06-04 18:44:03 +00:00
|
|
|
int
|
|
|
|
ReuseString (const char *str)
|
|
|
|
{
|
2002-07-05 20:02:10 +00:00
|
|
|
return strpool_addstr (pr.strings, str);
|
2002-06-04 18:44:03 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 13:16:08 +00:00
|
|
|
ex_value_t *
|
2011-03-22 03:24:39 +00:00
|
|
|
convert_value (ex_value_t *value, type_t *type)
|
|
|
|
{
|
2022-11-16 08:55:56 +00:00
|
|
|
if (!is_math (type) || !is_math (value->type)) {
|
|
|
|
error (0, "unable to convert non-math value");
|
2012-12-05 13:16:08 +00:00
|
|
|
return value;
|
2011-03-22 03:24:39 +00:00
|
|
|
}
|
2022-11-16 08:55:56 +00:00
|
|
|
if (type_width (type) != type_width (value->type)) {
|
|
|
|
error (0, "unable to convert between values of different widths");
|
|
|
|
return value;
|
2011-03-22 03:24:39 +00:00
|
|
|
}
|
2022-11-16 08:55:56 +00:00
|
|
|
int from = type_cast_map[base_type (value->type)->type];
|
|
|
|
int to = type_cast_map[base_type (type)->type];
|
|
|
|
int width = type_width (value->type) - 1;
|
|
|
|
int conv = TYPE_CAST_CODE (from, to, width);
|
|
|
|
int addr = value_functions[vf_convert].first_statement;
|
|
|
|
value_statements[addr + 0].b = conv;
|
2022-11-16 11:48:58 +00:00
|
|
|
value_statements[addr + 1].c = type_size (type) - 1;
|
2022-11-16 08:55:56 +00:00
|
|
|
memcpy (value_globals, &value->v,
|
|
|
|
type_size (value->type) * sizeof (pr_type_t));
|
|
|
|
value_pr.pr_trace = options.verbosity > 1;
|
|
|
|
PR_ExecuteProgram (&value_pr, vf_convert);
|
|
|
|
return new_type_value (type, value_pr.pr_return_buffer);
|
2011-03-22 03:24:39 +00:00
|
|
|
}
|
|
|
|
|
2012-12-23 10:25:35 +00:00
|
|
|
ex_value_t *
|
|
|
|
alias_value (ex_value_t *value, type_t *type)
|
|
|
|
{
|
|
|
|
ex_value_t new;
|
|
|
|
|
2018-10-12 13:05:17 +00:00
|
|
|
if (type_size (type) != type_size (ev_types[value->lltype])) {
|
2012-12-23 10:25:35 +00:00
|
|
|
error (0, "unable to alias different sized values");
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
new = *value;
|
2018-10-12 13:05:17 +00:00
|
|
|
set_val_type (&new, type);
|
2012-12-23 10:25:35 +00:00
|
|
|
return find_value (&new);
|
|
|
|
}
|
|
|
|
|
2012-12-01 11:53:58 +00:00
|
|
|
static immediate_t *
|
2012-12-21 04:17:07 +00:00
|
|
|
make_def_imm (def_t *def, hashtab_t *tab, ex_value_t *val)
|
2012-12-01 11:53:58 +00:00
|
|
|
{
|
|
|
|
immediate_t *imm;
|
|
|
|
|
2022-07-26 12:36:56 +00:00
|
|
|
imm = aligned_alloc (__alignof__(immediate_t), sizeof (immediate_t));
|
|
|
|
memset (imm, 0, sizeof (immediate_t));
|
2012-12-01 11:53:58 +00:00
|
|
|
imm->def = def;
|
2012-12-21 04:17:07 +00:00
|
|
|
memcpy (&imm->i, &val->v, sizeof (imm->i));
|
2012-12-01 11:53:58 +00:00
|
|
|
|
|
|
|
Hash_AddElement (tab, imm);
|
|
|
|
|
|
|
|
return imm;
|
|
|
|
}
|
|
|
|
|
2001-06-26 07:21:20 +00:00
|
|
|
def_t *
|
2011-02-13 01:09:42 +00:00
|
|
|
emit_value (ex_value_t *value, def_t *def)
|
2001-06-26 07:21:20 +00:00
|
|
|
{
|
2002-05-16 21:57:03 +00:00
|
|
|
def_t *cn;
|
2001-12-06 19:49:40 +00:00
|
|
|
hashtab_t *tab = 0;
|
|
|
|
type_t *type;
|
2011-02-13 01:09:42 +00:00
|
|
|
ex_value_t val = *value;
|
2001-06-26 07:21:20 +00:00
|
|
|
|
|
|
|
if (!string_imm_defs) {
|
2002-06-28 16:00:01 +00:00
|
|
|
clear_immediates ();
|
2001-06-26 07:21:20 +00:00
|
|
|
}
|
2002-05-16 21:57:03 +00:00
|
|
|
cn = 0;
|
2018-10-12 13:05:17 +00:00
|
|
|
// if (val.type == ev_void)
|
|
|
|
// val.type = type_nil->type;
|
|
|
|
switch (val.lltype) {
|
2011-01-18 23:41:24 +00:00
|
|
|
case ev_entity:
|
|
|
|
case ev_func:
|
2022-01-18 04:21:06 +00:00
|
|
|
case ev_int:
|
|
|
|
case ev_uint:
|
2011-01-18 23:41:24 +00:00
|
|
|
case ev_float:
|
2022-04-29 02:27:27 +00:00
|
|
|
case ev_vector:
|
|
|
|
case ev_quaternion:
|
|
|
|
case ev_double:
|
2022-11-16 11:48:58 +00:00
|
|
|
case ev_long:
|
|
|
|
case ev_ulong:
|
2022-04-29 02:27:27 +00:00
|
|
|
tab = value_imm_defs;
|
|
|
|
type = val.type;
|
|
|
|
break;
|
|
|
|
case ev_field:
|
|
|
|
case ev_ptr:
|
|
|
|
tab = fldptr_imm_defs;
|
|
|
|
type = ev_types[val.lltype];
|
2001-06-26 07:21:20 +00:00
|
|
|
break;
|
2011-01-18 23:41:24 +00:00
|
|
|
case ev_string:
|
2022-01-18 04:21:06 +00:00
|
|
|
val.v.int_val = ReuseString (val.v.string_val);
|
2001-06-26 07:21:20 +00:00
|
|
|
tab = string_imm_defs;
|
|
|
|
type = &type_string;
|
|
|
|
break;
|
|
|
|
default:
|
2022-04-29 02:27:27 +00:00
|
|
|
internal_error (0, "unexpected value type: %s",
|
|
|
|
val.type->type < ev_type_count
|
|
|
|
? pr_type_name[val.lltype]
|
|
|
|
: va (0, "%d", val.lltype));
|
2001-06-26 07:21:20 +00:00
|
|
|
}
|
2022-04-29 02:27:27 +00:00
|
|
|
def_t search_def = { .type = type };
|
|
|
|
immediate_t search = { .def = &search_def };
|
2011-02-13 01:09:42 +00:00
|
|
|
memcpy (&search.i, &val.v, sizeof (search.i));
|
2022-04-29 02:27:27 +00:00
|
|
|
immediate_t *imm = Hash_FindElement (tab, &search);
|
2003-04-22 15:29:32 +00:00
|
|
|
if (imm && strcmp (imm->def->name, ".zero") == 0) {
|
|
|
|
if (def) {
|
|
|
|
imm = 0; //FIXME do full def aliasing
|
|
|
|
} else {
|
2011-01-25 23:01:24 +00:00
|
|
|
symbol_t *sym;
|
2012-12-02 01:11:30 +00:00
|
|
|
sym = make_symbol (".zero", &type_zero, 0, sc_extern);
|
2011-01-25 23:01:24 +00:00
|
|
|
return sym->s.def;
|
2003-04-22 15:29:32 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-20 03:31:49 +00:00
|
|
|
if (imm) {
|
|
|
|
cn = imm->def;
|
2001-06-26 07:21:20 +00:00
|
|
|
if (def) {
|
2011-01-24 06:41:43 +00:00
|
|
|
defspace_free_loc (def->space, def->offset, type_size (def->type));
|
|
|
|
def->offset = cn->offset;
|
2001-10-18 17:41:22 +00:00
|
|
|
def->initialized = def->constant = 1;
|
2003-04-25 17:00:22 +00:00
|
|
|
def->nosave = 1;
|
2007-09-15 07:58:39 +00:00
|
|
|
def->local = 0;
|
2001-06-26 07:21:20 +00:00
|
|
|
cn = def;
|
2001-11-14 05:08:37 +00:00
|
|
|
} else {
|
|
|
|
if (cn->type != type) {
|
2012-12-02 01:11:30 +00:00
|
|
|
def = new_def (".imm", type, pr.near_data, sc_static);
|
2011-01-24 06:41:43 +00:00
|
|
|
def->offset = cn->offset;
|
2001-11-14 05:08:37 +00:00
|
|
|
cn = def;
|
|
|
|
}
|
2001-06-26 07:21:20 +00:00
|
|
|
}
|
|
|
|
return cn;
|
|
|
|
}
|
|
|
|
// allocate a new one
|
|
|
|
// always share immediates
|
|
|
|
if (def) {
|
2001-11-13 18:11:19 +00:00
|
|
|
if (def->type != type) {
|
2012-12-02 01:11:30 +00:00
|
|
|
cn = new_def (".imm", type, pr.near_data, sc_static);
|
2011-01-24 06:41:43 +00:00
|
|
|
cn->offset = def->offset;
|
2001-11-13 18:11:19 +00:00
|
|
|
} else {
|
|
|
|
cn = def;
|
|
|
|
}
|
2001-06-26 07:21:20 +00:00
|
|
|
} else {
|
2012-12-02 01:11:30 +00:00
|
|
|
cn = new_def (".imm", type, pr.near_data, sc_static);
|
2001-06-26 07:21:20 +00:00
|
|
|
}
|
2001-10-18 17:41:22 +00:00
|
|
|
cn->initialized = cn->constant = 1;
|
2003-04-25 17:00:22 +00:00
|
|
|
cn->nosave = 1;
|
2001-06-26 07:21:20 +00:00
|
|
|
// copy the immediate to the global area
|
2018-10-12 13:05:17 +00:00
|
|
|
switch (val.lltype) {
|
2011-01-18 23:41:24 +00:00
|
|
|
case ev_string:
|
2011-02-12 13:34:38 +00:00
|
|
|
reloc_def_string (cn);
|
2002-07-11 22:38:23 +00:00
|
|
|
break;
|
2011-01-18 23:41:24 +00:00
|
|
|
case ev_func:
|
2012-11-21 01:06:15 +00:00
|
|
|
if (val.v.func_val.val) {
|
2011-02-12 13:34:38 +00:00
|
|
|
reloc_t *reloc;
|
|
|
|
reloc = new_reloc (cn->space, cn->offset, rel_def_func);
|
|
|
|
reloc->next = pr.relocs;
|
|
|
|
pr.relocs = reloc;
|
|
|
|
}
|
2002-07-11 22:38:23 +00:00
|
|
|
break;
|
2011-01-18 23:41:24 +00:00
|
|
|
case ev_field:
|
2011-02-13 01:09:42 +00:00
|
|
|
if (val.v.pointer.def)
|
|
|
|
reloc_def_field_ofs (val.v.pointer.def, cn);
|
2004-11-12 10:49:00 +00:00
|
|
|
break;
|
2022-01-18 05:36:06 +00:00
|
|
|
case ev_ptr:
|
2011-02-13 01:09:42 +00:00
|
|
|
if (val.v.pointer.def) {
|
2011-01-24 06:41:43 +00:00
|
|
|
EMIT_DEF_OFS (pr.near_data, D_INT (cn),
|
2011-02-13 01:09:42 +00:00
|
|
|
val.v.pointer.def);
|
2005-06-09 10:34:03 +00:00
|
|
|
}
|
2002-07-14 03:41:13 +00:00
|
|
|
break;
|
2002-07-11 22:38:23 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2001-06-26 07:21:20 +00:00
|
|
|
|
2022-04-26 06:10:00 +00:00
|
|
|
memcpy (D_POINTER (pr_type_t, cn), &val.v, 4 * type_size (type));
|
2001-06-26 07:21:20 +00:00
|
|
|
|
2018-09-08 13:23:57 +00:00
|
|
|
make_def_imm (cn, tab, &val);
|
2002-10-20 03:31:49 +00:00
|
|
|
|
2001-06-26 07:21:20 +00:00
|
|
|
return cn;
|
|
|
|
}
|
2002-06-28 16:00:01 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
clear_immediates (void)
|
|
|
|
{
|
2012-12-01 11:53:58 +00:00
|
|
|
def_t *def;
|
2012-12-21 04:17:07 +00:00
|
|
|
ex_value_t zero_val;
|
2002-10-20 03:31:49 +00:00
|
|
|
|
2012-07-18 14:01:09 +00:00
|
|
|
if (value_table) {
|
|
|
|
Hash_FlushTable (value_table);
|
2002-06-28 16:00:01 +00:00
|
|
|
Hash_FlushTable (string_imm_defs);
|
2022-04-29 02:27:27 +00:00
|
|
|
Hash_FlushTable (fldptr_imm_defs);
|
|
|
|
Hash_FlushTable (value_imm_defs);
|
2002-06-28 16:00:01 +00:00
|
|
|
} else {
|
2022-11-16 08:55:56 +00:00
|
|
|
setup_value_progs ();
|
|
|
|
|
2020-03-25 06:43:16 +00:00
|
|
|
value_table = Hash_NewTable (16381, 0, 0, 0, 0);
|
2012-07-18 14:01:09 +00:00
|
|
|
Hash_SetHashCompare (value_table, value_get_hash, value_compare);
|
|
|
|
|
2020-03-25 06:43:16 +00:00
|
|
|
string_imm_defs = Hash_NewTable (16381, 0, imm_free,
|
|
|
|
&string_imm_defs, 0);
|
2002-10-20 03:31:49 +00:00
|
|
|
Hash_SetHashCompare (string_imm_defs, imm_get_hash, imm_compare);
|
|
|
|
|
2022-04-29 02:27:27 +00:00
|
|
|
fldptr_imm_defs = Hash_NewTable (16381, 0, imm_free,
|
|
|
|
&fldptr_imm_defs, 0);
|
|
|
|
Hash_SetHashCompare (fldptr_imm_defs, imm_get_hash, imm_compare);
|
2020-02-14 11:08:59 +00:00
|
|
|
|
2022-04-29 02:27:27 +00:00
|
|
|
value_imm_defs = Hash_NewTable (16381, 0, imm_free,
|
|
|
|
&value_imm_defs, 0);
|
|
|
|
Hash_SetHashCompare (value_imm_defs, imm_get_hash, imm_compare);
|
2002-06-28 16:00:01 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 01:11:30 +00:00
|
|
|
def = make_symbol (".zero", &type_zero, 0, sc_extern)->s.def;
|
2012-12-01 11:53:58 +00:00
|
|
|
|
2012-12-21 04:17:07 +00:00
|
|
|
memset (&zero_val, 0, sizeof (zero_val));
|
|
|
|
make_def_imm (def, string_imm_defs, &zero_val);
|
2022-04-29 02:27:27 +00:00
|
|
|
make_def_imm (def, fldptr_imm_defs, &zero_val);
|
|
|
|
make_def_imm (def, value_imm_defs, &zero_val);
|
2002-06-28 16:00:01 +00:00
|
|
|
}
|