From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1A34E384D166 for ; Mon, 6 Jun 2022 22:19:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1A34E384D166 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-QecQAgQtM3-BYpWSh-YJzw-1; Mon, 06 Jun 2022 18:19:00 -0400 X-MC-Unique: QecQAgQtM3-BYpWSh-YJzw-1 Received: by mail-qk1-f198.google.com with SMTP id w22-20020a05620a445600b006a6c18678f2so2746369qkp.4 for ; Mon, 06 Jun 2022 15:19:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=t/Kgxjlq2vN72om0sTollTf9PfKRauTGXRshntJl23U=; b=zaEeVPVpVcBXtJdNhlvEKX81Ub1itAcHdV6xIyeo5F3YO90Yjt/A96mz2ndBRywvbE WSIii89CrlI/f5aQYlIiuDCddQN9SbacZ0Vm5cOOEwCOuDAWhgcbiLiKn3PuAkpVL990 738ezQA5M7AIwHLx/JNX4/2bv2vNhZdXSijwl5twsqOJcR6wFFl3RedLqzlTjhxgc30f v03sSJ/7TQKe7/0W6Hs4eDzJvxGvPYURl7ezygPtQuqcX26m6LVhxwKpTqpynduw/4bP NxyEgMEcGNuCzDFRXFvowdROmHV7lsOslzRQJMA29B68SA+H3E6Lk+Gy3iayxpYeJIpR 1nxg== X-Gm-Message-State: AOAM532a4Zy0p6j8fMSkdWBycrM+9b+rqugTnM5oMtEVabni1EdRvHPk 1rusgXpxKKR+69dFMrmqQA8tSIQ+q4DyI7bsvKRSEsFgmTDRlmNxpUqGr0Ylt7ImONnbKbervO5 OKKsFFZE= X-Received: by 2002:a05:622a:112:b0:304:f0ea:7efb with SMTP id u18-20020a05622a011200b00304f0ea7efbmr3795820qtw.373.1654553940338; Mon, 06 Jun 2022 15:19:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzduTTGJK663P1lvzjbJ079kYOeZUTwgTK6M8a7X76SQuR9PsSCQmSX9DB0FxciM6iK9z+20A== X-Received: by 2002:a05:622a:112:b0:304:f0ea:7efb with SMTP id u18-20020a05622a011200b00304f0ea7efbmr3795804qtw.373.1654553940079; Mon, 06 Jun 2022 15:19:00 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id w4-20020a05620a444400b006a6278a2b31sm3222252qkp.75.2022.06.06.15.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 15:18:59 -0700 (PDT) Message-ID: <54e79555048630267719007f9c7aa348c8b5e57b.camel@redhat.com> Subject: Re: [PATCH] libgccjit: Support getting the size of a float From: David Malcolm To: Antoni Boucher , gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Date: Mon, 06 Jun 2022 18:18:58 -0400 In-Reply-To: References: User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jun 2022 22:19:04 -0000 On Thu, 2022-06-02 at 23:09 -0400, Antoni Boucher via Gcc-patches wrote: > Hi. > The attached patch fix bug 105829: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105829 > > Thanks for the review. > diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc > index cc6486c9cad..12e7679988b 100644 > --- a/gcc/jit/libgccjit.cc > +++ b/gcc/jit/libgccjit.cc > @@ -545,8 +545,8 @@ gcc_jit_type_get_size (gcc_jit_type *type) > { > RETURN_VAL_IF_FAIL (type, -1, NULL, NULL, "NULL type"); > RETURN_VAL_IF_FAIL > - (type->is_int (), -1, NULL, NULL, > - "only getting the size of an integer type is supported for now"); > + (type->is_int () || type->is_float (), -1, NULL, NULL, > + "only getting the size of an int or float type is supported for now"); Reword to: "only getting the size of integer or floating-point types is supported for now" to avoid using the words "int" and "float" to refer to those kinds of types, and to follow: https://gcc.gnu.org/codingconventions.html#Spelling > return type->get_size (); > } > > diff --git a/gcc/testsuite/jit.dg/test-types.c b/gcc/testsuite/jit.dg/test-types.c > index 6836597d14e..53bdeafed61 100644 > --- a/gcc/testsuite/jit.dg/test-types.c > +++ b/gcc/testsuite/jit.dg/test-types.c > @@ -489,4 +489,7 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) > CHECK (gcc_jit_compatible_types ( > gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_LONG), > gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT64_T))); > + > + CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT)), 4); > + CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), 8); I'm not sure these sizes are 4 and 8 on every target we support. I got curious and found e.g. gcc/config/rl78/rl78.h has: #define FLOAT_TYPE_SIZE 32 #define DOUBLE_TYPE_SIZE 32 /*64*/ Maybe use sizeof (float) and sizeof (double) in the assertion, rather than hardcoding the values? (though this still assumes host == target). Otherwise LGTM - OK for trunk with those nits fixed. Thanks Dave