From patchwork Fri Nov 27 09:22:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Pei X-Patchwork-Id: 41199 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B9D2B397249F; Fri, 27 Nov 2020 09:23:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 40C59397183F for ; Fri, 27 Nov 2020 09:22:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 40C59397183F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=huangpei@loongson.cn Received: from localhost.localdomain (unknown [182.149.161.68]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxf9NlxcBfFHAXAA--.16578S3; Fri, 27 Nov 2020 17:22:51 +0800 (CST) From: Huang Pei To: Joseph Myers Subject: [PATCH 1/3] mips: add hp-timing support for MIPS R2 Date: Fri, 27 Nov 2020 17:22:31 +0800 Message-Id: <20201127092233.29416-2-huangpei@loongson.cn> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201127092233.29416-1-huangpei@loongson.cn> References: <20201127092233.29416-1-huangpei@loongson.cn> X-CM-TRANSID: AQAAf9Dxf9NlxcBfFHAXAA--.16578S3 X-Coremail-Antispam: 1UD129KBjvJXoW7CFW7Gr1UZr4xAFW7CF17ZFb_yoW8Zr43pF 4kCFy5GF4vqrWak3yfAF43GF15tFs5Jr15GF13CFW5Jwn8JFy8XrW2qrW5G34xJFySkrZ7 ZFs7WFWUuFs7ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBa14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1Y6r1xM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_GFWl42xK82 IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC2 0s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMI IF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF 0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87 Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUBmhrUUUUU= X-CM-SenderInfo: xkxd0whshlqz5rrqw2lrqou0/ X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huacai Chen , Chenghua Xu , libc-alpha Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" MIPS R2 only support 32 bit TSC(AKA "rdhwr %0, $2"), but it should be enough for glibc Signed-off-by: Huang Pei --- sysdeps/mips/hp-timing.h | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sysdeps/mips/hp-timing.h diff --git a/sysdeps/mips/hp-timing.h b/sysdeps/mips/hp-timing.h new file mode 100644 index 0000000000..128315d0bf --- /dev/null +++ b/sysdeps/mips/hp-timing.h @@ -0,0 +1,43 @@ +/* High precision, low overhead timing functions. MIPS version. + Copyright (C) 2002-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _HP_TIMING_H +#define _HP_TIMING_H 1 + +#if __mips_isa_rev >= 2 +/* We always assume having the timestamp register. */ +#define HP_TIMING_AVAIL (0) +#define HP_SMALL_TIMING_AVAIL (1) + +/* We indeed have inlined functions. */ +#define HP_TIMING_INLINE (1) + +/* We use 32bit values for the times. */ +typedef unsigned int hp_timing_t; + +/* Read the cp0 count, this maybe inaccurate. */ +#define HP_TIMING_NOW(Var) \ + ({ unsigned int _count; \ + asm volatile ("rdhwr\t%0,$2" : "=r" (_count)); \ + (Var) = _count; }) + +#include + +#endif + +#endif /* hp-timing.h */