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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 698A6385780D for ; Sat, 31 Oct 2020 17:33:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 698A6385780D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-415-8YAL5fi7MpeaQ4I1tmqy9A-1; Sat, 31 Oct 2020 13:33:47 -0400 X-MC-Unique: 8YAL5fi7MpeaQ4I1tmqy9A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9EF4107AFB6; Sat, 31 Oct 2020 17:33:46 +0000 (UTC) Received: from ovpn-112-135.phx2.redhat.com (ovpn-112-135.phx2.redhat.com [10.3.112.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C06719D61; Sat, 31 Oct 2020 17:33:46 +0000 (UTC) Message-ID: Subject: Re: Spaghetti stack? From: David Malcolm To: Qiantan Hong , "jit@gcc.gnu.org" Date: Sat, 31 Oct 2020 13:33:45 -0400 In-Reply-To: <4C3839D5-645F-49FD-9A3B-27754F8F938A@mit.edu> References: <4C3839D5-645F-49FD-9A3B-27754F8F938A@mit.edu> User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, 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: 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: Sat, 31 Oct 2020 17:33:54 -0000 On Sat, 2020-10-31 at 05:58 +0000, Qiantan Hong wrote: > Hi, > > I’m trying to find a way to implement/hack > a runtime using spaghetti stack with libgccjit, I have to confess that I wasn't familiar with the term "spaghetti stack". > I think I need to tell libgccjit to use a different > calling convention, either implemented by > myself, or somehow let it use the “bare” > calling convention and generate prologue/ > epilogue myself. However, I didn’t find > any API about calling convention — neither > do I have any idea how to express the > prologue/epilogue with libgccjit because they’re > at register level. > > Any idea? That sounds lower level that the approach libgccjit takes; libgccjit's API tends to mimic what's expressible by the C frontend. I don't think libgccjit currently exposes a way to set the calling convention, but IIRC the C frontend does. Does an existing GCC frontend exposes a way of implementing any of this? If so, it can probably be exposed by libgccjit, otherwise we'd have to add support to GCC for it, which makes it much harder. Another approach would be to do it "by hand", by implementing the calling convention by injecting calls to dynamically allocate the frame, populate it, and then make a call with the parameters suitably modified - if that makes sense. Hope this is helpful Dave