lint: reduce preprocessor magic for platform target types

This commit is contained in:
rillig 2021-01-24 14:47:40 +00:00
parent ed5947a0ff
commit 8b04e96a79
23 changed files with 101 additions and 143 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.3 2021/01/09 14:10:12 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.4 2021/01/24 14:47:40 rillig Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -41,9 +41,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.6 2021/01/09 14:10:12 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.7 2021/01/24 14:47:40 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.7 2021/01/09 14:10:12 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.8 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.4 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.5 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.7 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.8 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.6 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.7 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.4 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.5 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.5 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.6 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.6 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.7 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.7 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.8 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -44,13 +44,13 @@
*/
#ifdef _LP64_X
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#else
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#endif
#define FLOAT_SIZE 32

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.7 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.8 2021/01/24 14:47:41 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -44,9 +44,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.3 2021/01/09 14:10:13 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.4 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.7 2021/01/09 14:10:14 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.8 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.4 2021/01/09 14:10:14 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.5 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.3 2021/01/09 14:10:14 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.4 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.3 2021/01/09 14:10:14 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.4 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.7 2021/01/09 14:10:14 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.8 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
#define INTPTR_IS_LONG 0
#define PTRDIFF_TSPEC INT
#define SIZEOF_TSPEC UINT
#define INTPTR_TSPEC INT
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.6 2021/01/09 14:10:14 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.7 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.7 2021/01/09 14:10:14 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.8 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.8 2021/01/09 14:10:15 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.9 2021/01/24 14:47:42 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -42,9 +42,9 @@
* or the value of sizeof is of type unsigned long. Note this MUST be
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: targparam.h,v 1.6 2021/01/09 14:10:15 rillig Exp $ */
/* $NetBSD: targparam.h,v 1.7 2021/01/24 14:47:43 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,9 +43,9 @@
* kept in sync with the compiler!
*/
#define PTRDIFF_IS_LONG 1
#define SIZEOF_IS_ULONG 1
#define INTPTR_IS_LONG 1
#define PTRDIFF_TSPEC LONG
#define SIZEOF_TSPEC ULONG
#define INTPTR_TSPEC LONG
#define FLOAT_SIZE 32
#define DOUBLE_SIZE 64

View File

@ -1,4 +1,4 @@
/* $NetBSD: inittyp.c,v 1.17 2021/01/17 13:50:32 rillig Exp $ */
/* $NetBSD: inittyp.c,v 1.18 2021/01/24 14:47:43 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: inittyp.c,v 1.17 2021/01/17 13:50:32 rillig Exp $");
__RCSID("$NetBSD: inittyp.c,v 1.18 2021/01/24 14:47:43 rillig Exp $");
#endif
#include <limits.h>
@ -48,11 +48,7 @@ __RCSID("$NetBSD: inittyp.c,v 1.17 2021/01/17 13:50:32 rillig Exp $");
/* various type information */
ttab_t ttab[NTSPEC];
#if INTPTR_IS_LONG
#define INT_RSIZE 3
#else
#define INT_RSIZE 4
#endif
#define INT_RSIZE (INTPTR_TSPEC == LONG ? 3 : 4)
void
inittyp(void)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.190 2021/01/24 11:34:01 rillig Exp $ */
/* $NetBSD: tree.c,v 1.191 2021/01/24 14:47:43 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: tree.c,v 1.190 2021/01/24 11:34:01 rillig Exp $");
__RCSID("$NetBSD: tree.c,v 1.191 2021/01/24 14:47:43 rillig Exp $");
#endif
#include <float.h>
@ -2659,13 +2659,8 @@ build_struct_access(op_t op, tnode_t *ln, tnode_t *rn)
ln = convert(NOOP, 0, tincref(gettyp(VOID), PTR), ln);
}
#if PTRDIFF_IS_LONG
ctn = new_integer_constant_node(LONG,
ctn = new_integer_constant_node(PTRDIFF_TSPEC,
rn->tn_sym->s_value.v_quad / CHAR_SIZE);
#else
ctn = new_integer_constant_node(INT,
rn->tn_sym->s_value.v_quad / CHAR_SIZE);
#endif
ntn = new_tnode(PLUS, tincref(rn->tn_type, PTR), ln, ctn);
if (ln->tn_op == CON)
@ -2792,11 +2787,7 @@ build_plus_minus(op_t op, tnode_t *ln, tnode_t *rn)
lint_assert(ln->tn_type->t_tspec == PTR);
lint_assert(op == MINUS);
#if PTRDIFF_IS_LONG
tp = gettyp(LONG);
#else
tp = gettyp(INT);
#endif
tp = gettyp(PTRDIFF_TSPEC);
ntn = new_tnode(op, tp, ln, rn);
if (ln->tn_op == CON && rn->tn_op == CON)
ntn = fold(ntn);
@ -2839,11 +2830,7 @@ build_colon(tnode_t *ln, tnode_t *rn)
lt = ln->tn_type->t_tspec;
rt = rn->tn_type->t_tspec;
#if PTRDIFF_IS_LONG
pdt = LONG;
#else
pdt = INT;
#endif
pdt = PTRDIFF_TSPEC;
/*
* Arithmetic types are balanced, all other type combinations
@ -2971,7 +2958,6 @@ static tnode_t *
plength(type_t *tp)
{
int elem, elsz;
tspec_t st;
lint_assert(tp->t_tspec == PTR);
tp = tp->t_subt;
@ -3023,13 +3009,8 @@ plength(type_t *tp)
if (elsz == 0)
elsz = CHAR_SIZE;
#if PTRDIFF_IS_LONG
st = LONG;
#else
st = INT;
#endif
return new_integer_constant_node(st, (int64_t)(elem * elsz / CHAR_SIZE));
return new_integer_constant_node(PTRDIFF_TSPEC,
(int64_t)(elem * elsz / CHAR_SIZE));
}
/*
@ -3324,13 +3305,7 @@ fold_float(tnode_t *tn)
tnode_t *
build_sizeof(type_t *tp)
{
tspec_t st;
#if SIZEOF_IS_ULONG
st = ULONG;
#else
st = UINT;
#endif
return new_integer_constant_node(st, tsize(tp) / CHAR_SIZE);
return new_integer_constant_node(SIZEOF_TSPEC, tsize(tp) / CHAR_SIZE);
}
/*
@ -3339,19 +3314,13 @@ build_sizeof(type_t *tp)
tnode_t *
build_offsetof(type_t *tp, sym_t *sym)
{
tspec_t st;
#if SIZEOF_IS_ULONG
st = ULONG;
#else
st = UINT;
#endif
tspec_t t = tp->t_tspec;
if (t != STRUCT && t != UNION)
/* unacceptable operand of '%s' */
error(111, "offsetof");
// XXX: wrong size, no checking for sym fixme
return new_integer_constant_node(st, tsize(tp) / CHAR_SIZE);
return new_integer_constant_node(SIZEOF_TSPEC, tsize(tp) / CHAR_SIZE);
}
int64_t
@ -3419,8 +3388,6 @@ tsize(type_t *tp)
tnode_t *
build_alignof(type_t *tp)
{
tspec_t st;
switch (tp->t_tspec) {
case ARRAY:
break;
@ -3454,13 +3421,8 @@ build_alignof(type_t *tp)
break;
}
#if SIZEOF_IS_ULONG
st = ULONG;
#else
st = UINT;
#endif
return new_integer_constant_node(st, (int64_t)getbound(tp) / CHAR_SIZE);
return new_integer_constant_node(SIZEOF_TSPEC,
(int64_t)getbound(tp) / CHAR_SIZE);
}
/*