From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id w9PrGqus0F9uDgAAWB0awg (envelope-from ) for ; Wed, 09 Dec 2020 05:53:31 -0500 Received: by simark.ca (Postfix, from userid 112) id 6117F1F0A9; Wed, 9 Dec 2020 05:53:31 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 14C811EF4B for ; Wed, 9 Dec 2020 05:53:30 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 951773857C5F; Wed, 9 Dec 2020 10:53:29 +0000 (GMT) Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by sourceware.org (Postfix) with ESMTPS id E69453857C5F for ; Wed, 9 Dec 2020 10:53:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E69453857C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x444.google.com with SMTP id l9so1203760wrt.13 for ; Wed, 09 Dec 2020 02:53:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4XG8Ch0mVjmm98q+O4Z+SYxbu1QhXIUqLYSRi7QEHGs=; b=C2609kZBlWOsv0Vav/vihrIRDDePwW2FT8DZqmhZT6eL94Ndfsb7lG4Nl5kPn0K1lk cJdqQgxF3exziyCm8MWlPa9GTFMqh8wsQUQfuUDn/0gZMqI2Znco2qmQa2cq8+u1C37d 39c8dgknG5jR4GFxlRTQwP3JE6wx/KPWCNnhwy15q8bimRG6eMN6Pwe56OJ6RUfef6vy hoLTUIf/2NNIYUUPA6VxKqYChA3Lp5rjgJPCdOJaYIwR/F+AG2/oCJC3Ty6KbaNf8u5W ru5PIeYnbPq+IhJZjAVsTXoOk5vrQtKqTMAQOGMlworlpgZ5YDxDpbNuKma2jickXVMf PZYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4XG8Ch0mVjmm98q+O4Z+SYxbu1QhXIUqLYSRi7QEHGs=; b=R0zK1cAImJ6NIDOaYYNuFYoN0HCeuQ/NDLoJ2wunqBLcQPtAk8nCcOuQWC8/vJPO9s gbyZ1j6g6zmcyvid1GYKNawgaPXFD1cWgCwDaYmladi3km3wuXhz8IlIIqSeGRGJ5v1E UlG/pCRQtcpeLaxQ/Ys7A3NefdpMeAwfAX2GIFTW06KemCjdBxNVdAJaMX22DKkQg4h/ LOymbcG3Oj3LUU50gHy6NcJ1GLArsPEwRGxbZbiBkOc1oBA5OK61phkFyxKyC/1ZYTLE PYRyY/a3DVSmxnl95iKN1J+nNKqpUvbMN669JB1Qw5cPISOaFt8ozrmWj5/cxczz4Ogw zZ7w== X-Gm-Message-State: AOAM533ty77RtKKfzWUPLPT4NB4hXfcXmSF8VU1YgX3+iKbWlY18N+6M sYcGDXr4OQYdjxG+RzF/a7GJWA== X-Google-Smtp-Source: ABdhPJx2zVh5F0JlHe7gMzEoQbqewkg8XJc/I5k4ELI9QAbmOdJzCTPL5vXvJgxirjHLN8khpJsqRw== X-Received: by 2002:a5d:554a:: with SMTP id g10mr2017208wrw.253.1607511205967; Wed, 09 Dec 2020 02:53:25 -0800 (PST) Received: from localhost (host109-154-20-215.range109-154.btcentralplus.com. [109.154.20.215]) by smtp.gmail.com with ESMTPSA id x66sm2405766wmg.26.2020.12.09.02.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 02:53:25 -0800 (PST) Date: Wed, 9 Dec 2020 10:53:24 +0000 From: Andrew Burgess To: Mike Frysinger Subject: Re: [PATCH] sim: common: add align_{up,down} to match gdb Message-ID: <20201209105324.GA2945@embecosm.com> References: <20201209064528.2661-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201209064528.2661-1-vapier@gentoo.org> X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 10:52:29 up 15:36, 1 user, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" * Mike Frysinger via Gdb-patches [2020-12-09 01:45:28 -0500]: > We have ALIGN_{8,16,PAGE} and FLOOR_PAGE macros (where PAGE is defined as > 4k) which were imported from the ppc sim. But no other sim utilizes these > and hardcoding the sizes in the name is a bit limiting. > > Let's delete these and import the two general macros that gdb uses: > align_up(addr, bytes) > align_down(addr, bytes) > > This in turn allows us to cut over the Blackfin code immediately. > --- > sim/bfin/ChangeLog | 5 +++++ > sim/bfin/interp.c | 7 ++++--- > sim/bfin/sim-main.h | 2 -- > sim/common/ChangeLog | 6 ++++++ > sim/common/sim-bits.h | 17 ++++------------- > 5 files changed, 19 insertions(+), 18 deletions(-) > > diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog > index 18f287323126..2384009cab80 100644 > --- a/sim/bfin/ChangeLog > +++ b/sim/bfin/ChangeLog > @@ -1,3 +1,8 @@ > +2020-12-09 Mike Frysinger > + > + * interp.c: Change ALIGN to align_up. > + * sim-main.h (ALIGN): Delete LGTM. Thanks, Andrew > + > 2020-08-21 Simon Marchi > > * configure.ac: Include config/pkg.m4. > diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c > index d884d1025c55..60ed6d73c393 100644 > --- a/sim/bfin/interp.c > +++ b/sim/bfin/interp.c > @@ -289,7 +289,7 @@ bfin_syscall (SIM_CPU *cpu) > sc.result = heap; > heap += sc.arg2; > /* Keep it page aligned. */ > - heap = ALIGN (heap, 4096); > + heap = align_up (heap, 4096); > > break; > } > @@ -948,7 +948,8 @@ bfin_fdpic_load (SIM_DESC sd, SIM_CPU *cpu, struct bfd *abfd, bu32 *sp, > } > > /* Update the load offset with a few extra pages. */ > - fdpic_load_offset = ALIGN (max (max_load_addr, fdpic_load_offset), 0x10000); > + fdpic_load_offset = align_up (max (max_load_addr, fdpic_load_offset), > + 0x10000); > fdpic_load_offset += 0x10000; > > /* Push the summary loadmap info onto the stack last. */ > @@ -1074,7 +1075,7 @@ bfin_user_init (SIM_DESC sd, SIM_CPU *cpu, struct bfd *abfd, > env_flat += strlen (env[i]); > > /* Push the Auxiliary Vector Table between argv/env and actual strings. */ > - sp_flat = sp = ALIGN (SPREG - argv_flat - env_flat - 4, 4); > + sp_flat = sp = align_up (SPREG - argv_flat - env_flat - 4, 4); > if (auxvt) > { > # define AT_PUSH(at, val) \ > diff --git a/sim/bfin/sim-main.h b/sim/bfin/sim-main.h > index e9fe76ed2c28..ed3ac80929de 100644 > --- a/sim/bfin/sim-main.h > +++ b/sim/bfin/sim-main.h > @@ -53,9 +53,7 @@ struct sim_state { > #include "dv-bfin_trace.h" > > #undef CLAMP > -#undef ALIGN > #define CLAMP(a, b, c) min (max (a, b), c) > -#define ALIGN(addr, size) (((addr) + ((size)-1)) & ~((size)-1)) > > /* TODO: Move all this trace logic to the common code. */ > #define BFIN_TRACE_CORE(cpu, addr, size, map, val) \ > diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog > index 2c71b1359042..98649924809e 100644 > --- a/sim/common/ChangeLog > +++ b/sim/common/ChangeLog > @@ -1,3 +1,9 @@ > +2020-12-09 Mike Frysinger > + > + * sim-bits.h (_ALIGNa, _FLOORa, ALIGN_8, ALIGN_16, ALIGN_PAGE, > + FLOOR_PAGE): Delete unused macros. > + (align_up, align_down): Define. > + > 2020-08-10 Tom de Vries > > * sim-cpu.c: Include stdlib.h for free. > diff --git a/sim/common/sim-bits.h b/sim/common/sim-bits.h > index 4b9de3796359..43f459cf8f4b 100644 > --- a/sim/common/sim-bits.h > +++ b/sim/common/sim-bits.h > @@ -92,11 +92,8 @@ > EXTEND*(VALUE): Convert the `*' bit value to the targets natural > word size. Sign extend the value if needed. > > - ALIGN_*(VALUE): Round the value upwards so that it is aligned to a > - `_*' byte boundary. > - > - FLOOR_*(VALUE): Truncate the value so that it is aligned to a `_*' > - byte boundary. > + align_*(VALUE, BYTES): Round the value so that it is aligned to a > + BYTES boundary. > > ROT*(VALUE, NR_BITS): Return the `*' bit VALUE rotated by NR_BITS > right (positive) or left (negative). > @@ -525,14 +522,8 @@ INLINE_SIM_BITS(unsigned_word) MSINSERTED (unsigned_word val, int start, int sto > > > /* memory alignment macro's */ > -#define _ALIGNa(A,X) (((X) + ((A) - 1)) & ~((A) - 1)) > -#define _FLOORa(A,X) ((X) & ~((A) - 1)) > - > -#define ALIGN_8(X) _ALIGNa (8, X) > -#define ALIGN_16(X) _ALIGNa (16, X) > - > -#define ALIGN_PAGE(X) _ALIGNa (0x1000, X) > -#define FLOOR_PAGE(X) ((X) & ~(0x1000 - 1)) > +#define align_up(v, n) (((v) + (n) - 1) & -(n)) > +#define align_down(v, n) ((v) & -(n)) > > > /* bit bliting macro's */ > -- > 2.28.0 >