issue #169 apply latest upstream changes

pull/212/head
Dibyendu Majumdar 3 years ago
parent 773ebd9d32
commit 56a59a1f31

@ -46,7 +46,10 @@
or IEEE quad precision FP values. If it is the same as double, the double type will be used instead.
So please don't expect machine-independence of MIR code working with long double values
* `MIR_T_P` -- pointer values. Depending on the target pointer value is actually 32-bit or 64-bit integer value
* `MIR_T_BLK` -- block data. This type can be used only for argument of function
* `MIR_T_BLK` .. `MIR_T_BLK + MIR_BLK_NUM - 1` -- block data with given case. This type can be used only
for argument of function. Different case numbers can denote different ways to pass the block data
on a particular target to implement the target call ABI. Currently there are 5 block
types (`MIR_BLK_NUM = 5`)
* `MIR_T_RBLK` -- return block data. This type can be used only for argument of function
* MIR textual representation of the types are correspondingly `i8`,
`u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `f`, `d`, `ld`, `p`,
@ -100,7 +103,8 @@
* A variable should have an unique name in the function
* A variable is represented by a structure of type `MIR_var_t`
* The structure contains variable name and its type
* The structure contains also type size for variable of `MIR_T_BLK` or `MIR_T_RBLK` type
* The structure contains also type size for variable of block types (`MIR_T_BLK`..`MIR_T_BLK + MIR_BLK_NUM - 1`)
or `MIR_T_RBLK` type
* MIR function with its arguments is created through API function `MIR_item_t MIR_new_func (MIR_context_t ctx, const
char *name, size_t nres, MIR_type_t *res_types, size_t nargs, ...)`
or function `MIR_item_t MIR_new_func_arr (MIR_context_t ctx, const char *name, size_t nres, MIR_type_t *res_types, size_t nargs, MIR_var_t *arg_vars)`
@ -408,8 +412,9 @@
* `MIR_VA_ARG` takes va_list and any memory operand and returns
address of the next argument in the 1st insn operand. The memory
operand type defines the type of the argument
* `MIR_VA_BLOCK_ARG` takes result address, va_list, and integer operand
and moves the next argument passed as block of give size to the result address
* `MIR_VA_BLOCK_ARG` takes result address, va_list address, integer operand (size),
and block type (case) number and moves the next argument passed as block of given
size and type to the result address
* va_list operand can be memory with undefined type. In this case
address of the va_list is not in the memory but is the
memory address

@ -2194,7 +2194,7 @@ static int replacement_eq_p (VARR (token_t) * r1, VARR (token_t) * r2) {
el1 = VARR_GET (token_t, r1, i);
el2 = VARR_GET (token_t, r2, i);
if (el1->code == ' ' && el2->code == ' ') return TRUE;
if (el1->code == ' ' && el2->code == ' ') continue;
if (el1->node_code != el2->node_code) return FALSE;
if (strcmp (el1->repr, el2->repr) != 0) return FALSE;
}
@ -2279,8 +2279,8 @@ static void define (c2m_ctx_t c2m_ctx) {
} else {
VARR (token_t) * temp;
warning (c2m_ctx, id->pos, "different macro redefinition of %s", name);
temp = m->params, m->params = params, params = temp;
temp = m->replacement, m->replacement = repl, repl = temp;
SWAP (m->params, params, temp);
SWAP (m->replacement, repl, temp);
}
}
VARR_DESTROY (token_t, repl);
@ -3752,6 +3752,7 @@ static void pre (c2m_ctx_t c2m_ctx, const char *start_source_name) {
typedef struct {
node_t id, scope;
int typedef_p;
} tpname_t;
DEF_HTAB (tpname_t);
@ -3849,12 +3850,13 @@ static int tpname_find (c2m_ctx_t c2m_ctx, node_t id, node_t scope, tpname_t *re
return found_p;
}
static tpname_t tpname_add (c2m_ctx_t c2m_ctx, node_t id, node_t scope) {
static tpname_t tpname_add (c2m_ctx_t c2m_ctx, node_t id, node_t scope, int typedef_p) {
parse_ctx_t parse_ctx = c2m_ctx->parse_ctx;
tpname_t el, tpname;
tpname.id = id;
tpname.scope = scope;
tpname.typedef_p = typedef_p;
if (HTAB_DO (tpname_t, tpname_tab, tpname, HTAB_FIND, el)) return el;
HTAB_DO (tpname_t, tpname_tab, tpname, HTAB_INSERT, el);
return el;
@ -4247,10 +4249,8 @@ D (declaration) {
decl = r;
last_pos = POS (decl);
assert (decl->code == N_DECL);
if (typedef_p) {
op = NL_HEAD (decl->u.ops);
tpname_add (c2m_ctx, op, curr_scope);
}
tpname_add (c2m_ctx, op, curr_scope, typedef_p);
try_attr_spec (c2m_ctx, last_pos);
if (M ('=')) {
P (initializer);
@ -4862,10 +4862,14 @@ D (direct_abstract_declarator) {
D (typedef_name) {
parse_ctx_t parse_ctx = c2m_ctx->parse_ctx;
node_t scope, r;
tpname_t tpn;
PTN (T_ID);
for (scope = curr_scope;; scope = scope->attr) {
if (tpname_find (c2m_ctx, r, scope, NULL)) return r;
if (tpname_find (c2m_ctx, r, scope, &tpn)) {
if (!tpn.typedef_p) break;
return r;
}
if (scope == NULL) break;
}
return err_node;
@ -5151,7 +5155,7 @@ err0:
D (transl_unit) {
parse_ctx_t parse_ctx = c2m_ctx->parse_ctx;
node_t list, ds, d, dl, r;
node_t list, ds, d, dl, r, func, param_list, p, par_declarator, id;
// curr_token->code = ';'; /* for error recovery */
read_token (c2m_ctx);
@ -5170,6 +5174,18 @@ D (transl_unit) {
PE (declaration, decl_err);
op_flat_append (c2m_ctx, dl, r);
}
func = NL_HEAD (NL_EL (d->u.ops, 1)->u.ops);
assert (func != NULL && func->code == N_FUNC);
param_list = NL_HEAD (func->u.ops);
for (p = NL_HEAD (param_list->u.ops); p != NULL; p = NL_NEXT (p)) {
if (p->code == N_ID) {
tpname_add (c2m_ctx, p, curr_scope, FALSE);
} else if (p->code == N_SPEC_DECL) {
par_declarator = NL_EL (p->u.ops, 1);
id = NL_HEAD (par_declarator->u.ops);
tpname_add (c2m_ctx, id, curr_scope, FALSE);
}
}
P (compound_stmt);
r = new_pos_node4 (c2m_ctx, N_FUNC_DEF, POS (d), ds, d, dl, r);
curr_scope = d->attr;

Loading…
Cancel
Save